简体   繁体   English

使用SOAP HTTPS和Duplex进行WCF绑定

[英]WCF Binding with SOAP HTTPS and Duplex

I've found myself in need of finding a WCF Binding that uses HTTPS/SOAP and must be duplex. 我发现自己需要找到一个使用HTTPS / SOAP且必须为双工的WCF绑定。 I was programmatically using NetTcpBinding before but the binding now has to be HTTPS/SOAP. 我以前曾经以编程方式使用NetTcpBinding,但是现在绑定必须是HTTPS / SOAP。 I did some research and it seems like it's not possible without creating your own CustomBinding. 我做了一些研究,似乎没有创建自己的CustomBinding是不可能的。

However I'm sort of at a lost in what to do (not very familiar with bindings and the setup). 但是,我对执行操作有些迷茫(对绑定和设置不是很熟悉)。 I can't seem to get correct binding elements for what I need: 我似乎无法获得所需的正确绑定元素:

    public class CustomHttpsBinding : CustomBinding
    {
        public CustomHttpsBinding() 
        {
        }


        public override BindingElementCollection CreateBindingElements()
        {
            ReliableSessionBindingElement https = new ReliableSessionBindingElement();

            SecurityBindingElement security = SecurityBindingElement.CreateCertificateOverTransportBindingElement();

            CompositeDuplexBindingElement duplex = new CompositeDuplexBindingElement();

            SslStreamSecurityBindingElement ssl = new SslStreamSecurityBindingElement();

            MessageEncodingBindingElement encoding = new GZipMessageEncodingBindingElement((MessageEncodingBindingElement)  new BinaryMessageEncodingBindingElement());

            HttpsTransportBindingElement transport = new HttpsTransportBindingElement();

            return new BindingElementCollection(new BindingElement[] { https, security, duplex, ssl, encoding, transport });

        }

It gives me an invalid operation exception when checking soap over secure transport requirements saying my contract is configured with an authentication mode that requires integrity and confidentiality. 在检查安全传输要求时说我的合同配置了要求完整性和机密性的身份验证模式,这给我一个无效的操作异常。 However the transport cannot provide integrity and confidentiality. 但是,运输无法提供完整性和机密性。

Seems like my HttpsTransportBindingElement is not correct? 好像我的HttpsTransportBindingElement不正确? I'm not sure. 我不确定。

Thanks 谢谢

edit: 编辑:

I did manage to get WSDualHttpBinding to work at one point, but it seems like HTTPS is not possible with it (as well as others on the internet which say it shouldn't even be used) 我确实设法使WSDualHttpBinding可以在某一时刻正常工作,但似乎HTTPS不可能用它(以及互联网上的其他人都说甚至不应该使用它)

HTTP isn't duplex protocol - its request / response - that's why wsDualHttpBinding uses two connections - one in each direction. HTTP不是双工协议-它的请求/响应-这就是wsDualHttpBinding使用两个连接的原因-每个方向一个。 Silverlight achieves duplex over HTTP by polling for messages from the client under the covers Silverlight通过在幕后轮询来自客户端的消息来实现HTTP上的双工

NetTcpBinding uses TCP which can quite happily be duplex NetTcpBinding使用TCP,它可以很高兴地是双工的

If you can wait until 4.5 is released later this year this has the NetHttpBinding which does duplex using the WebSocket protocol 如果您可以等到今年晚些时候发布4.5,则可以使用NetHttpBinding,它使用WebSocket协议进行双工

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM