调用操作:EndpointDispatcher上的ContractFilter不匹配

时间:2018-01-26 15:22:34

标签: wcf web-config net.tcp

我在这个问题上看了几个小时。我尝试运行WCF服务,现在归结为一个ContractFilter-Mismatch-Error,其中包含Action" http://tempuri.org/ISystemService/LogIn"。以下是客户端配置的相关部分:

<bindings>
  <netTcpBinding>
    <binding name="netTcpBindingConfig_TimeRegistrationSystemService" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
            <security mode="Transport">  
                <transport clientCredentialType="Windows" />  
            </security>
        </binding>
        <binding name="netTcpBindingConfig_SystemService" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
            <security mode="Transport">  
                <transport clientCredentialType="Windows" />  
            </security>
        </binding>
  </netTcpBinding>    
</bindings>
<client>
  <endpoint address="net.tcp://mysrv.myteam.local:54520/MyCompany.Services.TimeRegistrationSystemService.svc" binding="netTcpBinding" bindingConfiguration="netTcpBindingConfig_SystemService" contract="SystemService.ISystemService" name="NetTcpBindingBinding_ISystemService" />
  <endpoint address="net.tcp://mysrv.myteam.local:54520/MyCompany.Services.SystemService.svc" binding="netTcpBinding" bindingConfiguration="netTcpBindingConfig_TimeRegistrationSystemService" contract="TimeRegistrationSystemService.ITimeRegistrationSystemService" name="NetTcpBindingBinding_ITimeRegistrationSystemService" />      
</client> 

这里是服务器的配置绑定配置:

<bindings>
    <netTcpBinding>
        <binding name="netTcpBindingConfig_OtherInterfaceService">
            <security mode="Transport">  
                <transport clientCredentialType="Windows" />  
            </security>
        </binding>
        <binding name="netTcpBindingConfig_TimeRegistrationSystemService" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
            <security mode="Transport">  
                <transport clientCredentialType="Windows" />  
            </security>
        </binding>
        <binding name="netTcpBindingConfig_SystemService" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
            <security mode="Transport">  
                <transport clientCredentialType="Windows" />  
            </security>
        </binding>
  </netTcpBinding>      
</bindings>

服务器的配置 - 服务:

<service name="MyCompany.Services.EasyLogicInterfaceService" behaviorConfiguration="release">
    <endpoint address="" binding="netTcpBinding" bindingConfiguration="netTcpBindingConfig_EasyLogicInterfaceService" contract="MyCompany.Services.IEasyLogicInterfaceService">          
    </endpoint>        
    <host>
      <baseAddresses>
        <add baseAddress="net.tcp://mysrv.myteam.local:54520/MyCompany.Services.EasyLogicInterfaceService.svc/" />
      </baseAddresses>
    </host>
  </service>
  <service name="MyCompany.Services.TimeRegistrationSystemService" behaviorConfiguration="release">
    <endpoint address="" binding="netTcpBinding" bindingConfiguration="netTcpBindingConfig_TimeRegistrationSystemService" contract="MyCompany.Services.ITimeRegistrationSystemService">          
    </endpoint>        
    <host>
      <baseAddresses>
        <add baseAddress="net.tcp://mysrv.myteam.local:54520/MyCompany.Services.SystemService.svc/" />
      </baseAddresses>
    </host>
  </service>
 <service name="MyCompany.Services.SystemService" behaviorConfiguration="release">
    <endpoint address="" binding="netTcpBinding" bindingConfiguration="netTcpBindingConfig_SystemService" contract="MyCompany.Services.ISystemService">          
    </endpoint>        
    <host>
      <baseAddresses>
        <add baseAddress="net.tcp://mysrv.myteam.local:54520/MyCompany.Services.SystemService.svc/" />
      </baseAddresses>
    </host>
  </service>

和行为:

<serviceBehaviors>
    <behavior name = "debug">
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
    <behavior name = "release">
      <serviceMetadata httpGetEnabled="false" httpsGetEnabled="false" />
      <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
  </serviceBehaviors>

我首先想到这可能是一个错字但我找不到它(我是不是会失明?!?)。我已经在客户端解决方案中更新了我的服务引用,然后发布了服务器代码和客户端代码。而且,我已经通过copy&#39; n&#39;粘贴来从服务器配置(绑定配置,端点addesses等)中将所有相关字符串放在客户端配置中以避免输入错误。

我在stackoverflow上遇到很多答案而没有找到解决问题的方法。

我可以在本地运行客户端和服务器代码而不会出现问题。问题仅在部署后发生。

通过system.diagnostics跟踪调用并不会显示除此错误消息之外的其他内容。

你看到的比我更多,或者你知道引发这种错误的任何问题吗?当出现此错误时,客户端和服务器之间的连接已经成功建立,对吧?所以它不是Kerberos或其他东西的问题......

如果事实证明它确实只是一个错字,我会事先道歉。但我找不到任何......

祝你好运!

1 个答案:

答案 0 :(得分:1)

<client>
  <endpoint address="net.tcp://mysrv.myteam.local:54520/MyCompany.Services.TimeRegistrationSystemService.svc"... contract="SystemService.ISystemService" name="NetTcpBindingBinding_ISystemService" />
  <endpoint address="net.tcp://mysrv.myteam.local:54520/MyCompany.Services.SystemService.svc"... contract="TimeRegistrationSystemService.ITimeRegistrationSystemService" name="NetTcpBindingBinding_ITimeRegistrationSystemService" />      
</client>

客户端配置端点具有反向合同。

根据您的service.config,对于 TimeRegistrationSystemService .svc,合同应为 ITimeRegistrationSystemService ,对于 SystemService .svc,合同应为的 ISystemService