2012-07-01 20 views
1

如何将此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> 

感谢提前!

+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 
+0

嘿,谢谢,但是,我之前做过,服务正在返回一个“错误的请求”=( – user1494757

+0

请参阅我的编辑现在的错误 –

+0

好吧,我正在生成正确的请求,但是,我需要以相同的编程方式进行,因为我没有私钥,私钥存储在HSM设备中,所以,为了能够使用服务,我需要以相同的编程方式...我从msdn中找到一些C#代码,但代码也是如此复杂的我..从msdn“WF_WCF_Samples”样品有一些项目来创建自定义令牌,但我根本不明白...我不知道该怎么办... :( – user1494757