2011-01-27 186 views
1

我在WCF中遇到了一个令我疯狂的问题。它是:WCF部署问题

由于EndpointDispatcher上的ContractFilter不匹配,无法在接收方处理具有Action'GetUserByUserNameAndPassword'的消息。这可能是因为合同不匹配(发件人和收件人之间的操作不匹配)或发件人和收件人之间的绑定/安全性不匹配。检查发送方和接收方是否有相同的合同和相同的绑定(包括安全要求,例如消息,传输,无)。

设置如下。我有一台Web服务器在IIS 7中运行客户端网站,该客户端尝试使用WCF与另一台服务器进行通信,该服务器在IIS 7中具有SQL Server和托管WCF服务。

这两台机器位于同一个域中。

尝试将其剥离为无,我试图让这个工作没有安全。客户端的配置是这样的:

<bindings> 
    <wsHttpBinding> 
     <binding name="wsHttpBinding_Normal"> 
     <security mode="None"/> 
     </binding> 
    </wsHttpBinding> 
</bindings> 

<client> 
    <endpoint address="http://192.168.1.10:3026/DS.Service/AuditLogger.svc" 
    binding="wsHttpBinding" bindingConfiguration="wsHttpBinding_Normal" 
    contract="AuditLogger.IAuditLogger" name="wsHttpBinding_IAuditLogger"> 
     <identity> 
      <dns value="localhost" /> 
     </identity> 
    </endpoint> 
</client> 

然后在服务器上的配置是这样的:

<bindings> 
    <wsHttpBinding> 
     <binding name="NormalTrafficBinding"> 
     <security mode="None"/> 
     </binding> 
    </wsHttpBinding> 
</bindings> 

<services> 
    <service name="DS.Service.ServiceImplementation.AuditLogger"> 
     <endpoint address="http://192.168.1.10:3026/DS.Service/AuditLogger.svc" 
     binding="wsHttpBinding" bindingConfiguration="NormalTrafficBinding" 
     contract="DS.Service.ServiceContracts.IAuditLogger"> 
      <identity> 
       <dns value="localhost" /> 
      </identity> 
     </endpoint> 
    </service> 
<services> 

本身看起来像这样的方法:

[OperationContract(IsTerminating = false, IsInitiating = true, IsOneWay = false, AsyncPattern = false, Action = "GetUserByUserNameAndPassword")] 
    [FaultContract(typeof(DS.Service.FaultContracts.DSOfficeFault))] 
    System.Data.DataSet GetUserByUserNameAndPassword(string userName, string password); 
+0

你更新一个服务器端的代码,忘了任何机会,以更新/重新创建另一台机器上该服务器的客户端代理? – 2011-01-27 15:14:25

回答

1

你必须定义两端(服务器和客户端)的合同相同。尽管它们都被称为IAuditLogger,但它们可能具有不同的签名。尝试在一个单独的程序集中只放置一个IAuditLogger类,然后在两个配置文件中引用它,或者确保两个IAuditLogger具有相同的方法。

你可能有这样的事情:

<client> 
<endpoint address="http://192.168.1.10:3026/DS.Service/AuditLogger.svc" 
binding="wsHttpBinding" bindingConfiguration="wsHttpBinding_Normal" 
contract="AuditLogger.IAuditLogger" name="wsHttpBinding_IAuditLogger"> 
    <identity> 
     <dns value="localhost" /> 
    </identity> 
</endpoint> 

而且

<services> 
<service name="DS.Service.ServiceImplementation.AuditLogger"> 
    <endpoint address="http://192.168.1.10:3026/DS.Service/AuditLogger.svc" 
    binding="wsHttpBinding" bindingConfiguration="NormalTrafficBinding" 
    contract="AuditLogger.IAuditLogger"> 
     <identity> 
      <dns value="localhost" /> 
     </identity> 
    </endpoint> 
</service> 

+0

不,这是**不真实** - 如果您从Visual Studio中执行标准的“添加服务引用”,则客户端代理将生成一个单独的名称空间,并且合约将是相同的它被序列化),但它存在于一个单独的客户端名称空间中! – 2011-01-27 15:12:46