【问题标题】:WCF and ContractFilter mismatch at the EndpointDispatcherEndpointDispatcher 处的 WCF 和 ContractFilter 不匹配
【发布时间】:2013-03-09 23:38:14
【问题描述】:

我得到了以下错误..有什么问题?

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

  1. WSModules.svc

    <%@ ServiceHost language="C#" Service="WS.Modules.ServiceContracts.WSModules"%>
    
  2. WSModules

    namespace WS.Modules.ServiceContracts
    {
        [ServiceBehavior(AddressFilterMode = AddressFilterMode.Any)]
        public class WSModules : IWSModules
        {  
            public string XmlData(string id)
            {
                return "You requested product" + id;
            }
        }
    }
    
  3. IWSModules

    namespace WS.Interfaces.ServiceContracts
    {
            [ServiceContract]
            public interface IWSModules
            {
                    [OperationContract]
                    [WebGet(UriTemplate = "XmlData?id={id}")]
                    string XmlData(string id);
            }
    }
    
  4. Web.config

    <system.serviceModel>   
    <behaviors>
    <serviceBehaviors>       
            <!-- ### WSModules -->
            <behavior name="WSModulesBehavior">
              <serviceMetadata httpGetEnabled="True" />
              <serviceDebug includeExceptionDetailInFaults="true" />
              <serviceThrottling maxConcurrentCalls="24" maxConcurrentSessions="24" />
            </behavior>
          </serviceBehaviors>
          <endpointBehaviors>
            <behavior name="web">
              <webHttp/>
            </behavior>
          </endpointBehaviors>      
        </behaviors>
    <services>   
          <!--  ### WSModules Service-->
          <service behaviorConfiguration="WSModulesBehavior" name="WS.Modules.ServiceContracts.WSModules">
            <endpoint address="" binding="webHttpBinding" contract="WS.Interfaces.ServiceContracts.IWSModules"/>       
                    <host>
                      <baseAddresses>
                        <add baseAddress="http://xxx.xxx.xxx/commonwebsol/wswsdl" />
                      </baseAddresses>
                    </host>
                  </service>
                </services>
                <serviceHostingEnvironment multipleSiteBindingsEnabled="True"/>
              </system.serviceModel>
    
  5. 我打开浏览器并输入 http://xxx.xxx.xxx/commonwebsol/WSWSDL/WSModules.svc - 工作正常。 我得到了“svcutil.exe http://xxx.xxx.xxx/commonwebsol/WSWSDL/WSModules.svc?wsdl 然后如果我点击“http://xxx.xxx.xxx/commonwebsol/WSWSDL/WSModules.svc?wsdl”我得到了 xml

  6. 但是,如果我在探索浏览器中输入 http://xxx.xxx.xxx/commonwebsol/WSWSDL/WSModules.svc?XmlData?id=123 我收到以下错误...

    <Text xml:lang="en-US">The message with Action '' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a         contract mismatch (mismatched Actions between sender and receiver) or a binding/security         mismatch between the sender and the receiver. Check that sender and         receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).</Text> 
    

【问题讨论】:

    标签: wcf wcf-binding


    【解决方案1】:

    如下更改您的端点属性

    endpoint address="" binding="webHttpBinding" behaviorConfiguration="web" contract="WS.Interfaces.ServiceContracts.IWSModules" 
    

    这会很好。

    【讨论】:

      猜你喜欢
      • 2014-04-16
      • 2019-07-20
      • 2013-02-21
      • 1970-01-01
      • 2011-03-28
      • 1970-01-01
      • 1970-01-01
      • 2011-07-26
      • 2018-07-05
      相关资源
      最近更新 更多