4

我正在编写一个使用 WSHttpFederationBinding 发布端点的 C# WCF 服务。我们有自己的安全令牌服务器提供令牌,调用者需要使用自定义绑定。

这对于我编写的 C# 客户端来说一切正常:这在其 app.config 中有一个自定义绑定,如下所示:

<bindings>
  <customBinding>
    <binding name="CustBind">
      <security authenticationMode="UserNameForCertificate" requireDerivedKeys="true"
                messageProtectionOrder="SignBeforeEncryptAndEncryptSignature"
                requireSecurityContextCancellation="false"
                requireSignatureConfirmation="false">
        <secureConversationBootstrap/>
      </security>
      <httpTransport/>
    </binding>
  </customBinding>
  <wsFederationHttpBinding>
    <binding name="FedBind">
      <security>
        <message issuedTokenType="http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1"
                 negotiateServiceCredential="false">
          <issuer address="http://STSHost/MySTS" binding="customBinding"
                  bindingConfiguration="CustBind">
            <identity>
              <certificateReference x509FindType="FindBySubjectName" findValue="localhost"/>
            </identity>
          </issuer>
        </message>
      </security>
    </binding>
  </wsFederationHttpBinding>
</bindings>

但是,我希望用户能够以他们想要的任何语言生成他们自己的客户端,只要给定 WCF 服务发布的 WSDL。这样做的问题是,当我使用 Developer Studio 的“添加服务引用”功能尝试这样的事情时,生成的客户端不起作用。

它不起作用的原因是生成的客户端的 app.config 显然是错误的:虽然 STS 存在于“issuer”元素中,但没有自定义绑定的迹象。看看 WSDL,这并不太令人惊讶,因为除了发行人地址之外没有提到任何其他内容。

有没有办法让 WCF 在 WSDL 中添加一些内容来描述这种情况?我的服务器的 app.config 绑定对我来说看起来不错:“发布者”元素与工作客户端完全相同,包括自定义绑定的地址和详细信息。有谁知道为什么 WCF 在生成 WSDL 时似乎忽略了这一点?

4

0 回答 0