4
votes

I am trying to test my Rest Wcf service from the Browser. WhenI am trying to send some values from browser I am getting the following error. "The message cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher.
Check that the sender and receiver's EndpointAddresses agree."

Then I added [ServiceBehavior(AddressFilterMode = AddressFilterMode.Any)]. then I am getting a different error.

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

Can we pass values to a Rest Wcf Service from a browser??

I am trying to passing following values from the browser.

http://mywebsite/Service1.svc/mymethod/Firstname,Lastname,LosAngles,CA

here is my web.confg file

<system.serviceModel>
    <services>              
      <service behaviorConfiguration="Wcfservice1.ServiceBehavior" name="="Wcfservice1.Service1">
        <endpoint address="" binding="webHttpBinding" contract="Wcfservice1.IService1">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>    
    <behaviors>
      <serviceBehaviors>        
        <behavior name="Wcfservice1.ServiceBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>    
  </system.serviceModel>
1
I can't find the <webHttp/> endpoint behavior in your config. Unless you've specified the "WebServiceHostFactory" in the Service1.svc file this is missing, and might even account for the error you're getting. - mthierba
Really. Where do I add <webHttp/> tag. Whatever the code is there in web.config is generated by VS2008.I am new to wcf.Can you please provide me some code. Thanks for your help. - Henry
<behaviors><endpointBehaviors><behavior name="REST"><webHttp/></behavior></endpointBehaviors></behaviors>. And you need to link to that behavior from your endpoint: <endpoint address="" behaviorConfiguration="REST" binding="webHttpBinding" contract="..." /> - carlosfigueira
Hi ,Thanks for the help. It seems the problem with the error is fixed.But Now I am getting "Method not allowed" dialog is displayed. But my method is POST only which sends data to wcf and wcf saves the data to Database. Why I am getting this error. - Henry

1 Answers

8
votes

It looks like you didn't enable the <webHttp/> behavior on the REST endpoint. Add this inside the <behaviors/> element in your config file:

  <endpointBehaviors>
    <behavior name="REST">
      <webHttp />
    </behavior>
  </endpointBehaviors>

Then, change the <endpoint/> element like this:

<endpoint address="" binding="webHttpBinding" behaviorConfiguration="REST" contract="Wcfservice1.IService1">