相同的WCF绑定配置,但仅在一个上有错误

时间:2013-10-10 12:35:02

标签: c# wcf wcf-binding nettcpbinding wcf-endpoint

所以我有一个带有2个ServiceContracts + MEX的WCF服务。这就是3个端点。

连接到每个服务合同的两个端点使用netTcpBinding并使用相同的bindingConfiguration

从一个地方我必须使用这两种服务。客户端的配置是相同的,但我在代理呼叫(contractFilter mismatch)上的一个例外但是没有另外一个例外。怎么可能。如果机器人配置是相同的,并且两个配置也可以如何工作而不是另一个。

请注意,问题服务是双工类型。

以下是两份服务合约:

[ServiceContract(SessionMode = SessionMode.Required, Name = "VpUser")]
public interface IVpClientService

[ServiceContract(SessionMode = SessionMode.Required, Name = "VpAdmin", CallbackContract = typeof(IAdminCallback))] 
public interface IVpAdminService

[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession, ConcurrencyMode = ConcurrencyMode.Multiple, IncludeExceptionDetailInFaults = true)]
public partial class VpService : IVpClientService, IVpAdminService, IServiceBehavior

服务端的web.config:

<system.serviceModel>
    <diagnostics performanceCounters="Off">
        <messageLogging logEntireMessage="true" logMalformedMessages="false"
        logMessagesAtServiceLevel="false" logMessagesAtTransportLevel="false" />
        <endToEndTracing messageFlowTracing="true" />
    </diagnostics>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
    <bindings>
        <netTcpBinding>
            <binding name="VpNetTcpBinding" portSharingEnabled="true"  closeTimeout="00:02:00" openTimeout="00:02:00"
                 receiveTimeout="00:22:00" sendTimeout="00:24:00" maxReceivedMessageSize="131072" >
                <reliableSession enabled="false" inactivityTimeout="00:50:00"/>
                <security mode="Transport"  >
                    <transport clientCredentialType="Windows" />
                </security>
            </binding>
        </netTcpBinding>
        <mexHttpBinding>
            <binding name="mexHttpBinding" closeTimeout="00:02:00" openTimeout="00:02:00"
                 receiveTimeout="00:02:00" sendTimeout="00:02:00" />
        </mexHttpBinding>
    </bindings>
    <services>
        <service behaviorConfiguration="VpServiceBehavior" name="VP.VpService.VpService">
            <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration="mexHttpBinding"
          name="MexMetadata" contract="IMetadataExchange" listenUriMode="Explicit" />
            <endpoint binding="netTcpBinding" bindingConfiguration="VpNetTcpBinding"
          name="HttpClient" contract="VP.VpService.IVpClientService">
                <identity>
                    <dns />
                </identity>
            </endpoint>
            <endpoint binding="netTcpBinding" bindingConfiguration="VpNetTcpBinding"
          name="HttpAdminClient" contract="VP.VpService.IVpAdminService">
                <identity>
                    <dns />
                </identity>
            </endpoint>
        </service>
    </services>
    <behaviors>
        <serviceBehaviors>
            <behavior name="VpServiceBehavior">
                <serviceDebug includeExceptionDetailInFaults="true" />
                <serviceMetadata httpGetEnabled="true" httpsGetEnabled="false" />
                <serviceThrottling
            maxConcurrentCalls="32"
            maxConcurrentSessions="100"
            maxConcurrentInstances="132"
            />
            </behavior>
        </serviceBehaviors>
    </behaviors>
</system.serviceModel>

和客户端的配置:

<system.serviceModel>
    <bindings>
        <netTcpBinding>
            <binding name="HttpClient" closeTimeout="00:01:00" openTimeout="00:01:00"
                    receiveTimeout="00:06:00" sendTimeout="00:06:00" transactionFlow="false"
                    transferMode="Buffered" transactionProtocol="OleTransactions"
                    hostNameComparisonMode="StrongWildcard" listenBacklog="10"
                    maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10"
                    maxReceivedMessageSize="65536">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
              maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <reliableSession ordered="true" inactivityTimeout="01:01:00"
              enabled="false" />
                <security mode="Transport">
                    <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
                    <message clientCredentialType="Windows" />
                </security>
            </binding>
            <binding name="HttpAdminClient" closeTimeout="00:01:00" openTimeout="00:01:00"
            receiveTimeout="00:06:00" sendTimeout="00:01:00" transactionFlow="false"
            transferMode="Buffered" transactionProtocol="OleTransactions"
            hostNameComparisonMode="StrongWildcard" listenBacklog="10"
            maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10"
            maxReceivedMessageSize="65536">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
              maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <reliableSession ordered="true" inactivityTimeout="01:01:00"
                           enabled="false" />
                <security mode="Transport">
                    <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
                    <message clientCredentialType="Windows" />
                </security>
            </binding>
        </netTcpBinding>
    </bindings>
    <client>
        <endpoint address="net.tcp://MyDomain:443/SubDomain/vpservice.svc"
            binding="netTcpBinding" bindingConfiguration="HttpClient"
            contract="VPService.VpUser" name="HttpClient">
            <identity>
                <dns />
            </identity>
        </endpoint>
        <endpoint address="net.tcp://MyDomain:443/SubDomain//vpservice.svc"
          binding="netTcpBinding" bindingConfiguration="HttpAdminClient"
          contract="VPService.VpAdmin" name="HttpAdminClient">
            <identity>
                <dns />
            </identity>
        </endpoint>
    </client>
</system.serviceModel>

请注意,HTTP名称前缀是在将其更改为netTcp之前的遗留物。

所以我可以构建代理和open()但是只要我做了一些异步调用(一个到Admin客户端,两个到另一个)我在管理员上遇到了一个Contract Mismathc错误但是另一个两次成功运行。

怎么可能?

0 个答案:

没有答案