VB.net 客户端上的soap 标头身份验证

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15127512/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 12:34:15  来源:igfitidea点击:

soap header authentication on a VB.net client

vb.netweb-servicessoapheaderwsdl

提问by user642318

I am developing VB.net client(excel) to connect to a thrid party webservice(java) that do not expose the authentication method on the WSDL.

我正在开发 VB.net 客户端(excel)以连接到不公开 WSDL 上的身份验证方法的第三方网络服务(java)。

How can I pass username and password in the header for the request. There is no explaination on the how the soap header must be?

如何在请求的标头中传递用户名和密码。没有解释肥皂头必须如何?

The document only say the following:

该文件仅说明以下内容:

Communication for Web services is provided through the basicHttpBinding in WCF. This binding supports WSS SOAP Message Security, WS-Security Username Token Profile, and WS-Security X.509 Certificate Security. The tested, certified, and supported configuration uses Transport Credential security mode with Windows Credentials. "A Web service client must pass the user name and password of the Windows account in the SOAP header to identify the correct Windows client to the server and database tiers."

Web 服务的通信是通过 WCF 中的 basicHttpBinding 提供的。此绑定支持 WSS SOAP 消息安全性、WS-Security 用户名令牌配置文件和 WS-Security X.509 证书安全性。经过测试、认证和支持的配置使用带有 Windows 凭据的传输凭据安全模式。“Web 服务客户端必须在 SOAP 标头中传递 Windows 帐户的用户名和密码,以向服务器和数据库层标识正确的 Windows 客户端。”

Thanks.

谢谢。

So any comment would be appreciated. I have gone to most of the threads in stackoverflow. Most of them is authentication method which is set on the server side which is not applicable in this case as I have no control over the webservices.

所以任何评论将不胜感激。我已经访问了 stackoverflow 中的大部分线程。其中大多数是在服务器端设置的身份验证方法,在这种情况下不适用,因为我无法控制网络服务。

This is a one-to-one client server relationship.

这是一对一的客户端服务器关系。

回答by user642318

yeap, I have done the credentials part. Obviously I copy and paste from other person who have found the solution for this.

是的,我已经完成了凭据部分。显然,我是从其他找到解决方案的人那里复制和粘贴的。

import System.Net; 
.... 
dim myService as New wsService
dim myCredentials as New Sustem.Net.CredentialCache()
dim netCrd as Ne NetworkCredential(UserName,Password,Domain)
myCredentials.Add(New Uri(wsServiceUrl), "Basic", netCred)
myService.UseDefaultCredentials = false
myService.Credentials = myCredentials

dim Data1 as new DataResponse
dataResponse = myService.getData("param1")

The getData method is called via the proxy method.

getData 方法通过代理方法调用。

However, I still have no idea of customizing the Username and Password on the header, as I have checked the xml request, i could not see any header tags.

但是,我仍然不知道自定义标题上的用户名和密码,因为我检查了 xml 请求,我看不到任何标题标签。

Any good comments would be appreciated.

任何好的评论将不胜感激。