Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send HTTP Auth Credentials with a WCF Service Reference

I'm attempting to consume a HTTP Basic Auth Secured PHP WebService using VB.NET. I've so far managed to get 100% perfect integration by adding it as a Web Reference and doing the following:

Dim Credentials = New System.Net.NetworkCredential("username", "password")
Dim CredentialCache = New System.Net.CredentialCache()
CredentialCache.Add(New Uri(MyWebService.Url), "Basic", Credentials)
MyWebService.Credentials = CredentialCache
MyWebService.PreAuthenticate = True

I can also successfully add the webservice as a 'Service Reference' and this also works fine, as long as i turn off all HTTP authentication on the SOAP server.

My problem is that I can't find any documented means of sending basic HTTP Auth Credentials when using Service References as opposed to 'Web References'

Am I right in my understanding that 'Web References' are a legacy method of Web Service consumption?

like image 307
jthompson Avatar asked Sep 04 '09 15:09

jthompson


1 Answers

This example from MSDN shows a client implementation for WCF using Basic Authentication.

like image 199
jro Avatar answered Oct 11 '22 02:10

jro