我已将基于轴的 wsdl 导入到 VS 2008 项目中作为服务参考。
我需要能够传递安全详细信息(例如用户名/密码和随机数值)来调用基于轴的服务。
我已经考虑过为 wse 做这件事,我知道世界讨厌它(那里没有问题)
我对 WCF 的经验很少,但多亏了 SO,现在已经研究了如何物理调用端点,但不知道如何设置 SoapHeaders,如下图所示:
<S:Envelope
xmlns:S="http://www.w3.org/2001/12/soap-envelope"
xmlns:ws="http://schemas.xmlsoap.org/ws/2002/04/secext">
<S:Header>
<ws:Security>
<ws:UsernameToken>
<ws:Username>aarons</ws:Username>
<ws:Password>snoraa</ws:Password>
</ws:UsernameToken>
</wsse:Security>
•••
</S:Header>
•••
</S:Envelope>
非常感谢任何帮助
谢谢,马克
为了调用这些类型的服务,您通常会使用basicHttpBinding
(这是没有 WS-* 实现的 SOAP 1.1)或者然后wsHttpBinding
(SOAP 1.2,带有 WS-* 实现)。
主要问题是确保所有安全参数正确。我有一个类似的 Web 服务(基于 Java),我需要调用 - 这是我的设置和代码:
应用程序./web.config
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="SoapWithAuth" useDefaultWebProxy="false">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Basic" proxyCredentialType="None" realm="" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint name="SoapWithAuth"
address="http://yourserver:port/YourService"
binding="basicHttpBinding"
bindingConfiguration="SoapWithAuth"
contract="IYourService" />
</client>
</system.serviceModel>
然后在调用服务时在客户端代码中,您需要以下代码片段:
IYourServiceClient client = new IYourServiceClient();
client.ClientCredentials.UserName.UserName = "username";
client.ClientCredentials.UserName.Password = "top-secret";
这些帮助有用?
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)