[英]Rest Wcf service
I am trying to test my Rest Wcf service from the Browser. 我试图从浏览器测试我的Rest Wcf服务。 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. “由于EndpointDispatcher上的AddressFilter不匹配,无法在接收方处理消息。
Check that the sender and receiver's EndpointAddresses agree." 检查发件人和收件人的EndpointAddresses是否一致。“
Then I added [ServiceBehavior(AddressFilterMode = AddressFilterMode.Any)]. 然后我添加了[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. “由于EndpointDispatcher上的ContractFilter不匹配。这可能是由于合同不匹配(发送方和接收方之间的操作不匹配)或发送方与接收方之间的绑定/安全性不匹配。
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?? 我们可以从浏览器传递值到Rest Wcf服务吗?
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 这是我的web.confg文件
<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. 看起来您没有在REST端点上启用<webHttp/>
行为。 Add this inside the <behaviors/>
element in your config file: 在配置文件的<behaviors/>
元素中添加:
<endpointBehaviors>
<behavior name="REST">
<webHttp />
</behavior>
</endpointBehaviors>
Then, change the <endpoint/>
element like this: 然后,像这样更改<endpoint/>
元素:
<endpoint address="" binding="webHttpBinding" behaviorConfiguration="REST" contract="Wcfservice1.IService1">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.