Unable to Set Username and Password in SOAP Request


New member
Dec 13, 2010
Programming Experience
I'm attempting to consume a SOAP service that requires HTTP Basic Authentication (over HTTPS).

I'm using WSE 3.0 on Visual Studio 2008.

Here's the basics...
    Class SNCClient
        Inherits SoapClient
        Public Sub New(ByVal destination As EndpointReference)
        End Sub

        <SoapMethod("getRecords")> _
        Public Function RequestResponseMethod(ByVal envelope As SoapEnvelope) As SoapEnvelope
            Return MyBase.SendRequestResponse("getRecords", envelope)
        End Function
    End Class
And from Main

        Dim sncuri As Uri = New Uri("https://site.com/path.do?SOAP")
        Dim destination As EndpointReference = New EndpointReference(sncuri)
        Dim client As SNCClient = New SNCClient(destination)

            Dim result As SoapEnvelope = client.RequestResponseMethod(message)
        Catch ex As AsynchronousOperationException
        End Try
None of these objects contains anything that looks like 'Credentials' or 'HTTPHeaders'...

I've tried doing https://username:password@site.com/path.do?SOAP in my URI, without effect.

I've also tried going the more direct route, creating a SoapEnvelope and SoapSender separately, but they didn't have any credential related properties in their object either.

Finally, I tried consuming the WSDL directly through the "Add Service Reference". This consumed the service definition, but the object still doesn't contain anything related to credentials. All the online examples show

  proxy.SetClientCredentials(New UsernameToken("user","pass"))
But that method isn't available to my object.

I read that "to be able to use the WSS methods to access the security headers, the proxy class has to inherit Microsoft.Web.Services.WebServicesClientProtocol", but it didn't bother telling me how to do that.

I'm very frustrated with VB, right now... I'm pretty sure I could have implemented SOAP from basic HTTP and XML classes in less time than I've spent searching for this solution, and that's what I'll do tomorrow if this cry for help goes unanswered.

Top Bottom