Need to add username and password to SOAP header in VB.NET Web Service Client

放肆的年华 提交于 2019-12-11 03:24:55

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!