Vb.net 如何为wso2安全令牌服务创建.NET客户端

Vb.net 如何为wso2安全令牌服务创建.NET客户端,vb.net,wcf,wso2,soapui,wso2is,Vb.net,Wcf,Wso2,Soapui,Wso2is,我需要为wso2安全令牌服务创建一个.NET客户端 通常,我会创建一个简单的控制台或WinForm项目,向其添加一个服务引用。公开的WSDL将转换为一组类,我可以使用这些类查询服务并正确管理其响应 不幸的是,生成的请求和响应类是空的:只有类声明,没有任何属性或方法。这类似于另一个(未回答的)堆栈溢出问题中描述的行为 我在这篇论坛帖子中找到了一个服务请求示例:我将其用于SOAP UI 是否有一种适当的、可能是自动的方法来重新创建查询安全令牌服务所需的复杂数据结构 编辑 好的,在多次尝试之后,我已经

我需要为wso2安全令牌服务创建一个.NET客户端

通常,我会创建一个简单的控制台或WinForm项目,向其添加一个服务引用。公开的WSDL将转换为一组类,我可以使用这些类查询服务并正确管理其响应

不幸的是,生成的请求和响应类是空的:只有类声明,没有任何属性或方法。这类似于另一个(未回答的)堆栈溢出问题中描述的行为

我在这篇论坛帖子中找到了一个服务请求示例:我将其用于SOAP UI

是否有一种适当的、可能是自动的方法来重新创建查询安全令牌服务所需的复杂数据结构

编辑

好的,在多次尝试之后,我已经将上面论坛帖子中的SOAP请求减少到了从STS服务获得RequestSecurityTokenResponse所需的最小结构

    <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
  <soap:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
    <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
      <wsse:UsernameToken wsu:Id="UsernameToken-6D35592DCDDA26FFF3141578725699577">
        <wsse:Username>USERNAME HERE</wsse:Username>
        <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">PASSWORD HERE</wsse:Password>
      </wsse:UsernameToken>
      <wsu:Timestamp wsu:Id="TS-6D35592DCDDA26FFF3141578725699576">
        <wsu:Created>2014-11-12T10:14:16.995Z</wsu:Created>
        <wsu:Expires>2014-11-12T10:16:16.995Z</wsu:Expires>
      </wsu:Timestamp>
    </wsse:Security>
    <wsa:Action soap:mustUnderstand="1">http://schemas.xmlsoap.org/ws/2005/02/trust/RST/SCT</wsa:Action>
    <wsa:MessageID soap:mustUnderstand="1">uuid:6d4eab69-77f9-42b7-8d6b-1f710020fb0b</wsa:MessageID>
    <wsa:To soap:mustUnderstand="1">STS ENDPOINT ADDRESS HERE</wsa:To>
  </soap:Header>
  <soap:Body>
    <wst:RequestSecurityToken xmlns:wst="http://schemas.xmlsoap.org/ws/2005/02/trust">
      <wst:RequestType>http://schemas.xmlsoap.org/ws/2005/02/trust/Issue</wst:RequestType>
      <wst:TokenType>http://schemas.xmlsoap.org/ws/2005/02/sc/sct</wst:TokenType>
      <wst:Claims>
        <wsid:ClaimType Uri="http://wso2.org/claims/userid" xmlns:wsid="http://schemas.xmlsoap.org/ws/2005/05/identity"/>
      </wst:Claims>
    </wst:RequestSecurityToken>
  </soap:Body>
</soap:Envelope>

这里的用户名
这里的密码
2014-11-12T10:14:16.995Z
2014-11-12T10:16:16.995Z
http://schemas.xmlsoap.org/ws/2005/02/trust/RST/SCT
uuid:6d4eab69-77f9-42b7-8d6b-1F7100FB0B
这里是STS端点地址
http://schemas.xmlsoap.org/ws/2005/02/trust/Issue
http://schemas.xmlsoap.org/ws/2005/02/sc/sct
我在项目的app.config中成功地定义了一个wsHttpBinding,如下所示:

  <wsHttpBinding>
    <binding name="SendUsername"  messageEncoding="Text">
      <security mode ="TransportWithMessageCredential">
        <message clientCredentialType ="UserName"/>
        <transport clientCredentialType ="Basic" />
      </security>
    </binding>
  </wsHttpBinding>
<customBinding>
     <binding name="wso2carbon-stsSoap12Binding">
      <security defaultAlgorithmSuite="Default" authenticationMode="IssuedToken"
        requireDerivedKeys="true" securityHeaderLayout="Lax" includeTimestamp="true">
        <localClientSettings detectReplays="false" />
        <localServiceSettings detectReplays="false" />
        <issuedTokenParameters keyType ="SymmetricKey" tokenType ="http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV2.0">
          <issuer address =STS ENDPOINT ADDRESS HERE binding ="wsHttpBinding" bindingConfiguration ="SendUsername"/>
          <claimTypeRequirements>
            <add claimType ="http://wso2.org/claims/userid"/>
          </claimTypeRequirements>
        </issuedTokenParameters>
      </security>
      <textMessageEncoding messageVersion="Soap12" />
      <httpsTransport />
    </binding>
  </customBinding>

添加或不添加自定义绑定,如下所示:

  <wsHttpBinding>
    <binding name="SendUsername"  messageEncoding="Text">
      <security mode ="TransportWithMessageCredential">
        <message clientCredentialType ="UserName"/>
        <transport clientCredentialType ="Basic" />
      </security>
    </binding>
  </wsHttpBinding>
<customBinding>
     <binding name="wso2carbon-stsSoap12Binding">
      <security defaultAlgorithmSuite="Default" authenticationMode="IssuedToken"
        requireDerivedKeys="true" securityHeaderLayout="Lax" includeTimestamp="true">
        <localClientSettings detectReplays="false" />
        <localServiceSettings detectReplays="false" />
        <issuedTokenParameters keyType ="SymmetricKey" tokenType ="http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV2.0">
          <issuer address =STS ENDPOINT ADDRESS HERE binding ="wsHttpBinding" bindingConfiguration ="SendUsername"/>
          <claimTypeRequirements>
            <add claimType ="http://wso2.org/claims/userid"/>
          </claimTypeRequirements>
        </issuedTokenParameters>
      </security>
      <textMessageEncoding messageVersion="Soap12" />
      <httpsTransport />
    </binding>
  </customBinding>


然而,在这两种情况下,请求都会引发超时异常,通过WCF跟踪发出的请求,我可以看到它缺少Claims元素。有什么提示吗

请参阅本文

有关这方面的更多信息,请参阅:


在与WCF配置选项斗争了许多天后,我取得了部分成功

允许我从安全令牌服务获得响应的关键是,我意识到,从长远来看,我需要在联邦安全场景中操作。我不需要令牌本身,但我需要它来获得对其他服务进行身份验证的方法

考虑到这个选项,我开始探索WCF为这种场景提供了什么,并构建了以下配置选项:

  <wsFederationHttpBinding>
    <binding name="fs">
      <security mode="TransportWithMessageCredential">
        <message issuedKeyType="SymmetricKey" issuedTokenType ="http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV2.0">
          <issuer address = <!-- STS address here --> binding ="customBinding" bindingConfiguration ="StsBinding"/>
          <claimTypeRequirements>
            <add claimType="http://wso2.org/claims/userid" />
          </claimTypeRequirements>
        </message>
      </security>
    </binding>
  </wsFederationHttpBinding>


谢谢你的链接,但他们不能帮助我有两个原因。第一个问题是我没有访问服务配置的权限,第二个问题是样本是Java的,我需要一个.NET客户端