Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rest Wcf service

Tags:

c#

wcf

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>
like image 832
Henry Avatar asked Feb 24 '23 09:02

Henry


1 Answers

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">
like image 174
mthierba Avatar answered Mar 04 '23 04:03

mthierba