问题
I need to query a web service that basic authentication, putting the username and password in the request header. My client is written in VB.NET Visual Basic Express Edition 2010. I've added the web service to the Service References. It has auto-generated the appropriate classes for me. I've written the following very simple code:
Dim imageService As AverittWebServices.SendWebImageClient = New AverittWebServices.SendWebImageClient("SendWebImagePort")
Dim imageResult As String
imageResult = imageService.getAvailableImages("")
DisplayLabel.Text = imageResult
I get a response back from the service that indicates I need to have a username and password in the SOAP header. The problem is that I can't seem to find a way to insert the username and password into the header. I have them but don't have an obvious way to use them.
回答1:
I know the referenced code is in C#, but it shouldn't be difficult to get it going in VB.net:
http://imar.spaanjaars.com/363/how-do-i-pass-credentials-to-a-web-service-that-uses-basic-authentication
来源:https://stackoverflow.com/questions/5993562/need-to-add-username-and-password-to-soap-header-in-vb-net-web-service-client