WCF自定义绑定 - 服务响应,客户端不响应

时间:2016-10-13 12:59:56

标签: wcf wcf-binding

我有一个WCF服务,它一直在使用wsDualHttpBinding但是我正在重写它以使用customBinding来实现更好的可配置性。这是我的服务绑定:

<customBinding>
    <binding name="CodeServiceBinding" openTimeout="00:01:00">
        <transactionFlow transactionProtocol="WSAtomicTransactionOctober2004"/>
        <reliableSession acknowledgementInterval="00:00:00.2" flowControlEnabled="true"
            inactivityTimeout="00:05:00" maxPendingChannels="4" maxRetryCount="8"
            maxTransferWindowSize="8" ordered="true" reliableMessagingVersion="Default" />
        <compositeDuplex/>
        <oneWay maxAcceptedChannels="10">
            <channelPoolSettings idleTimeout="00:02:00" leaseTimeout="00:10:00" maxOutboundChannelsPerEndpoint="10" />
        </oneWay>
        <textMessageEncoding messageVersion="Soap12WSAddressing10"/>
        <httpTransport allowCookies="false" authenticationScheme="Anonymous" bypassProxyOnLocal="false"
                                        decompressionEnabled="true" keepAliveEnabled="true" manualAddressing="false"
                                        maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxPendingAccepts="0"
                                        maxReceivedMessageSize="2147483647" proxyAuthenticationScheme="Anonymous"
                                        transferMode="Buffered" unsafeConnectionNtlmAuthentication="false"
                                        useDefaultWebProxy="true" />
    </binding>
</customBinding>

客户端绑定:

<system.serviceModel xdt:Transform="Replace">
    <bindings>
        <customBinding>
            <binding name="Code.DualEndPoint" openTimeout="00:00:10" sendTimeout="00:00:10">
                <transactionFlow transactionProtocol="WSAtomicTransactionOctober2004"/>
                <reliableSession inactivityTimeout="00:05:00" />
                <compositeDuplex />
                <oneWay />
                <textMessageEncoding messageVersion="Soap12WSAddressing10" />
                <httpTransport authenticationScheme="Anonymous" />
            </binding>
        </customBinding>
    </bindings>
    <client>
        <endpoint address="http://1.2.3.4/Code/Code.svc"
      binding="customBinding" bindingConfiguration="Code.DualEndPoint"
      contract="CodeProxy.ICode" name="Code.DualEndPoint" />
    </client>
</system.serviceModel>

当我针对http://localhost/Code/Code.svc运行时,一切都很有效但是,只要我将客户端放在其他地方,它就不起作用了。我不认为这是防火墙问题,因为使用wsDualHttpBinding的旧版本可以正常工作。还因为我把它弄乱了。

两个版本都发送其CreateSequence请求

<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
    <s:Header>
        <a:Action s:mustUnderstand="1">http://schemas.xmlsoap.org/ws/2005/02/rm/CreateSequence</a:Action>
        <a:MessageID>urn:uuid:222d5f6a-cca4-4a4b-b8bc-3347b81b425a</a:MessageID>
        <a:ReplyTo>
            <a:Address>http://1.2.3.4:1234/CodeClient/8f191330-523a-4820-a784-46fe364aebcc</a:Address>
        </a:ReplyTo>
        <a:To s:mustUnderstand="1">http://hostname.com/Code/Code.svc</a:To>
    </s:Header>
    <s:Body>
        <CreateSequence xmlns="http://schemas.xmlsoap.org/ws/2005/02/rm">
            <AcksTo>
                <a:Address>http://1.2.3.4:1234/CodeClient/8f191330-523a-4820-a784-46fe364aebcc</a:Address>
            </AcksTo>
            <Offer>
                <Identifier>urn:uuid:f7a18edc-e79f-4d96-a90d-696d1055b592</Identifier>
            </Offer>
        </CreateSequence>
    </s:Body>
</s:Envelope>

并接收从服务接受的HTTP 202,但新客户端永远不会发送实际的函数调用请求。旧版本立即启动它,但新绑定会挂起,直到满足SendTimeout并引发异常。什么是我的新绑定等待它导致它不发送函数调用请求,我怎么能让它停止等待?谢谢!

1 个答案:

答案 0 :(得分:0)

通过在我的客户端绑定中省略clientBaseAddress元素中的<compositeDuplex/>,我想我的服务混淆了指向其响应的位置?我不知道。无论哪种方式,它现在正在使用这个更新的节点:

<compositeDuplex clientBaseAddress="http://1.2.3.4:1234/CodeClient"/>

<compositeDuplex/>在我的服务web.config中仍然没有属性。但是,现在我面临着一个不同的问题。以编程方式更新自定义绑定的clientBaseAddress证明是非常困难的。