Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher

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

The message with Action 'http://localhost:22219/MobileService.svc/GetProductCategories' 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 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 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.MobileServiceAspNetAjaxBehavior">

        </behavior>
      </endpointBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"
      multipleSiteBindingsEnabled="true" />
    <services>
      <service name="MobileService.MobileService">
        <endpoint address="" behaviorConfiguration="MobileService.MobileServiceAspNetAjaxBehavior"
          binding="webHttpBinding" contract="MobileService.MobileService"  />
      </service>
    </services>
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

</configuration>

can any one help me where i made mistake.

like image 373
MindFresher Avatar asked Jan 19 '13 09:01

MindFresher


1 Answers

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>
like image 197
carlosfigueira Avatar answered Sep 30 '22 05:09

carlosfigueira