配置 WCF 客户端 WIF .NET 4.5

本文关键字:NET WIF WCF 客户端 配置 | 更新日期: 2023-09-27 17:57:03

我从 STS 获取令牌时遇到问题。如果我使用 SoapUI,我会得到令牌。但是我不知道如何配置我的客户端应用程序以创建如下请求:

<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
  <s:Header>
    <a:Action s:mustUnderstand="1">http://docs.oasis-open.org/ws-sx/ws-trust/200512/RST/Issue</a:Action>
    <a:To s:mustUnderstand="1">https://.../idp/sts.wst</a:To>
    <o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
      <o:UsernameToken>
        <o:Username>xxxUSERxxx</o:Username>
        <o:Password>xxxPWxxx</o:Password>
      </o:UsernameToken>
    </o:Security>
  </s:Header>
  <s:Body>
    <trust:RequestSecurityToken Context="http://client.ws.com" xmlns:trust="http://docs.oasis-open.org/ws-sx/ws-trust/200512">
      <wsp:AppliesTo xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
        <a:EndpointReference>
          <a:Address>xxxADDRESSxxx</a:Address>
        </a:EndpointReference>
      </wsp:AppliesTo>
      <trust:KeyType>http://docs.oasis-open.org/ws-sx/ws-trust/200512/Bearer</trust:KeyType>
      <trust:RequestType>http://docs.oasis-open.org/ws-sx/ws-trust/200512/Issue</trust:RequestType>
      <trust:TokenType>http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV2.0</trust:TokenType>
    </trust:RequestSecurityToken>
  </s:Body>
</s:Envelope>

有人可以帮助我吗?

配置 WCF 客户端 WIF .NET 4.5

STS 是否公开元数据交换终结点?如果是这样,您可以通过Visual Studio的"添加服务引用"对话框创建客户端代理(或仅使用svcutil)。

您可以使用本文作为起点。