无法在接收方处理,因为EndpointDispatcher的AddressFilter不匹配 [英] cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher

查看:5203
本文介绍了无法在接收方处理,因为EndpointDispatcher的AddressFilter不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用ajax启用WCF,当我在网络浏览器中打开网址,我得到这个错误。

I am using ajax enabled WCF, when i open the url in web browser i am getting this error.


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

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).

MobileService代码如下

MobileService code is given below

namespace MobileService
{
    [ServiceContract(Namespace = "")]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class MobileService
    {
        // To use HTTP GET, add [WebGet] attribute. (Default ResponseFormat is WebMessageFormat.Json)
        // To create an operation that returns XML,
        //     add [WebGet(ResponseFormat=WebMessageFormat.Xml)],
        //     and include the following line in the operation body:
        //         WebOperationContext.Current.OutgoingResponse.ContentType = "text/xml";
        [OperationContract]
        public void DoWork()
        {
            // Add your operation implementation here
            return;
        }
        [OperationContract]
        [WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "GetProductCategories")]
        public List<String> GetProductCategories()
        {
            List<String> categoryList = new List<string>();

            categoryList.AddRange(new String[] { "Electronics", "Housewares", "Computers", "Software", "Music" });

            return categoryList;
        }
        // Add more operations here and mark them with [OperationContract]
    }
}

AND
服务web.config文件是

AND Service web.config file is

<?xml version="1.0"?>
<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <behaviors>
      <endpointBehaviors>
        <behavior name="MobileService.webHttpBehavior">
          <webHttp />
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
    <services>
      <service name="MobileService.MobileService">
        <endpoint binding="webHttpBinding" contract="MobileService.MobileService" />
      </service>
    </services>
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
</configuration>

可以帮助我犯错误。

推荐答案

您的端点需要一个< webHttp /> 端点行为。

You need a <webHttp/> endpoint behavior for your endpoint. If you add that (see below) it should work.

  <endpointBehaviors>
    <behavior name="MobileService.MobileServiceAspNetAjaxBehavior">
      <webHttp/>
    </behavior>
  </endpointBehaviors>

这篇关于无法在接收方处理,因为EndpointDispatcher的AddressFilter不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆