我需要查询基本身份验证的Web服务,将用户名和密码放在请求标头中 . 我的客户端是用VB.NET Visual Basic Express Edition 2010编写的 . 我已将Web服务添加到服务引用中 . 它为我自动生成了适当的类 . 我编写了以下非常简单的代码:
Dim imageService As AverittWebServices.SendWebImageClient = New AverittWebServices.SendWebImageClient("SendWebImagePort")
Dim imageResult As String
imageResult = imageService.getAvailableImages("")
DisplayLabel.Text = imageResult
我从服务中得到一个回复,表明我需要在SOAP标头中有一个用户名和密码 . 问题是我似乎无法找到一种方法将用户名和密码插入 Headers . 我有他们,但没有明显的方法来使用它们 .
1 回答
我知道引用的代码是在C#中,但要在VB.net中运行起来应该不难:
http://imar.spaanjaars.com/363/how-do-i-pass-credentials-to-a-web-service-that-uses-basic-authentication