0

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

连接到每个服务合同的两个端点使用 anetTcpBinding并使用相同的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()但是一旦我进行了一些异步调用(一个到管理员客户端,两个到另一个),我在管理员上得到了一个 Contract Mismathc 错误,但其他两个成功运行。

这个怎么可能?

4

0 回答 0