简体   繁体   中英

Rest Wcf service

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, eg 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>

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM