简体   繁体   English

由于EndpointDispatcher的ContractFilter不匹配,因此无法在接收方处理带有动作''的消息。

[英]The message with Action '' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher.

I created a service to be host in sharepoint 我创建了一个服务以托管在sharepoint中

Here's the svc code behind: 这是后面的svc代码:

   [ServiceBehavior(AddressFilterMode = AddressFilterMode.Any)]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class MyService: IMyService
    {
        public bool AddNewItem(string id, string msg)
        {
            return true;
        }

        public string GetAllItems(string id)
        {
            return "test";
        }
    }

Here's the interface 这是界面

[ServiceContract]
interface IMyService
{
    [OperationContract]
    [WebGet(UriTemplate = "/GetAllItems/{id}",
          ResponseFormat = WebMessageFormat.Json)]
    string GetAllItems(string id);

    [OperationContract]
    [WebInvoke(Method = "POST", UriTemplate = "/AddNewItem",
        RequestFormat = WebMessageFormat.Json,
        ResponseFormat = WebMessageFormat.Json)]
    bool AddNewItem(string id, string msg);
}

And here's the web.config of the svc: 这是svc的web.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.serviceModel>
    <services>
      <service behaviorConfiguration="MyService.ISAPI.ServiceBehaviour" name ="MyService.MyService">
        <endpoint address="" binding="webHttpBinding"
                  contract="MyService.ISAPI.IMyService">

        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />

      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name ="MyService.ISAPI.ServiceBehaviour">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

Here's the app.config file: 这是app.config文件:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service name="MyService.MyService">
        <endpoint address="" binding="webHttpBinding" contract="MyService.ISAPI.IMyService">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8733/Design_Time_Addresses/MyService/MyService/" />
          </baseAddresses>
        </host>
      </service>
    </services>
  </system.serviceModel>
</configuration>

When I tried accessing the svc through the browser in this link www.mySharepoint.com/_vti_bin/MyService.svc/GetAllItems/1 , the below error occurs: 当我尝试通过浏览器通过此链接www.mySharepoint.com/_vti_bin/MyService.svc/GetAllItems/1访问svc时,发生以下错误:

The message with Action '' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. 由于EndpointDispatcher的ContractFilter不匹配,因此无法在接收方处理带有动作''的消息。 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, eg Message, Transport, None). 检查发送方和接收方是否具有相同的合同和相同的绑定(包括安全要求,例如,消息,传输,无)。

What is the problem? 问题是什么?

I think it's weird to have app.config and web.config at the same time, should I merge the config into one? 我认为同时拥有app.config和web.config很奇怪,我应该将配置合并为一个吗?

I found the answer, I was because I have to modify the sharepoint's web.config instead of creating one in the project. 我找到了答案,这是因为我必须修改共享点的web.config而不是在项目中创建一个。

In the sharepoint's web.config, I specified the endpoint 在共享点的web.config中,我指定了端点

    <service behaviorConfiguration="MyService.ISAPI.ServiceBehaviour" name ="MyService.MyService">
            <endpoint address="" binding="webHttpBinding"
                      contract="MyService.ISAPI.IMyService">

            </endpoint>
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />

  </service>

Now the problem is solved 现在问题解决了

将与端点相同的值分配给服务类/接口的ServiceContract属性的“名称空间”参数

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 由于EndpointDispatcher的ContractFilter不匹配,带有Action的消息无法在接收方处理 - The message with Action cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher 错误由于EndpointDispatcher的AddressFilter不匹配,带有To&#39;&#39;的消息无法在接收方处理 - Error The message with To '' cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher "由于 EndpointDispatcher 的 AddressFilter 不匹配,接收方无法处理带有 To &#39;...&#39; 的消息" - The message with To '...' cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher WCF 客户端不接受来自服务的响应。 由于 EndpointDispatcher 的 AddressFilter 不匹配,无法在接收方处理 - WCF Client does not accept response from service. Cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher 在EndpointDispatcher上ContractFilter不匹配? - ContractFilter mismatch at the EndpointDispatcher? EndpointDispatcher上的ContractFilter不匹配 - ContractFilter mismatch at the EndpointDispatcher 接收方无法处理带有动作“”的消息, - The message with Action '' cannot be processed at the receiver, WCF- ContractFilter在EndpointDispatcher上不匹配 - WCF- ContractFilter mismatch at the EndpointDispatcher EndpointDispatcher上的ContractFilter不匹配(错误处理) - ContractFilter mismatch at the EndpointDispatcher (error handling) WCF ContractFilter 在 EndpointDispatcher 错误处不匹配 - WCF ContractFilter mismatch at the EndpointDispatcher error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM