如何将此wcf基本绑定转换为自定义绑定?

时间:2012-07-01 20:53:03

标签: wcf

如何将此wcf基本绑定转换为自定义绑定??

      <basicHttpBinding>
    <binding name="BasicHttpBinding_IAutenticacion" closeTimeout="00:01:00"
      openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
      allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
      maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
      messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
      useDefaultWebProxy="true">
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
      <security mode="TransportWithMessageCredential">
        <transport clientCredentialType="None" proxyCredentialType="None"
          realm="" />
        <message clientCredentialType="Certificate" algorithmSuite="Default" />
      </security>
    </binding>
  </basicHttpBinding>

谢谢你!

1 个答案:

答案 0 :(得分:2)

查看在线wcf绑定转换器http://webservices20.blogspot.co.il/2009/08/bindingbox-convert-wcf-bindings.html

编辑:当您使用this service时,请记住在标记之前(如默认示例中那样)。然后结果将是:

<!-- generated via Yaron Naveh's http://webservices20.blogspot.com/ -->

<customBinding>
  <binding name="NewBinding0">
    <security authenticationMode="CertificateOverTransport" messageSecurityVersion="WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10" requireDerivedKeys="false" securityHeaderLayout="Lax" />
    <textMessageEncoding MessageVersion="Soap11" />
    <httpsTransport />
  </binding>
</customBinding>

<!-- generated via Yaron Naveh's http://webservices20.blogspot.com/ -->

编辑:这是您从代码创建此绑定的方式:

        var b = new CustomBinding();
        var s = SecurityBindingElement.CreateCertificateOverTransportBindingElement(
            MessageSecurityVersion.WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10);
        s.SetKeyDerivation(false);
        s.SecurityHeaderLayout = SecurityHeaderLayout.Lax;

        b.Elements.Add(s);
        b.Elements.Add(new TextMessageEncodingBindingElement() {  MessageVersion = MessageVersion.Soap11});
        b.Elements.Add(new HttpsTransportBindingElement());

创建客户端时,您可以设置如下证书:

c.ClientCredentials.ClientCertificate.Certificate
相关问题