需要在 VB.NET Web 服务客户端中将用户名和密码添加到 SOAP 标头

问题描述 投票:0回答:1

我需要查询一个进行基本身份验证的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 标头中包含用户名和密码。问题是我似乎找不到将用户名和密码插入标头的方法。我有它们,但没有明显的方法来使用它们。

vb.net web-services authentication soap client
1个回答
0
投票

我知道引用的代码是用 C# 编写的,但在 VB.net 中运行它应该不难:

http://imar.spaanjaars.com/363/how-do-i-pass-credentials-to-a-web-service-that-uses-basic-authentication

© www.soinside.com 2019 - 2024. All rights reserved.