加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net – 在WCF代理中实现Ws-security

发布时间:2020-12-16 09:58:05 所属栏目:asp.Net 来源:网络整理
导读:我已将基于轴的wsdl导入到VS 2008项目中作为服务引用. 我需要能够传递用户名/密码和nonce值等安全性详细信息来调用基于轴的服务. 我已经考虑过为wse做这件事,我理解世界讨厌(没有问题) 我对WCF的经验很少,但是现在已经研究了如何物理调用端点,感谢SO,但是不
我已将基于轴的wsdl导入到VS 2008项目中作为服务引用.

我需要能够传递用户名/密码和nonce值等安全性详细信息来调用基于轴的服务.

我已经考虑过为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),我需要调用 – 这是我的设置和代码:

app./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";

这些帮助有用?

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读