簡體   English   中英

由於EndpointDispatcher的ContractFilter不匹配,因此無法在接收方處理帶有動作''的消息。

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

我創建了一個服務以托管在sharepoint中

這是后面的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";
        }
    }

這是界面

[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);
}

這是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>

這是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>

當我嘗試通過瀏覽器通過此鏈接www.mySharepoint.com/_vti_bin/MyService.svc/GetAllItems/1訪問svc時,發生以下錯誤:

由於EndpointDispatcher的ContractFilter不匹配,因此無法在接收方處理帶有動作''的消息。 這可能是由於合同不匹配(發送方和接收方之間的操作不匹配)或發送方和接收方之間的綁定/安全不匹配造成的。 檢查發送方和接收方是否具有相同的合同和相同的綁定(包括安全要求,例如,消息,傳輸,無)。

問題是什么?

我認為同時擁有app.config和web.config很奇怪,我應該將配置合並為一個嗎?

我找到了答案,這是因為我必須修改共享點的web.config而不是在項目中創建一個。

在共享點的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>

現在問題解決了

將與端點相同的值分配給服務類/接口的ServiceContract屬性的“名稱空間”參數

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM