当试图用的WebHttpBinding开始我的WCF服务奇怪的错误我的、试图用、奇怪、错误

由网友(老夫聊发少年狂)分享简介:我收到当我尝试从一个Web浏览器的WebHttpBinding服务 连接到我的WCF这个奇怪的错误:Sendera:ActionNotSupportedThe消息动作''不能在接收器进行处理时,由于一个错配ContractFilter在EndpointDispatcher。这可能是因为一个合同不匹配或发送方和接收方之间...

我收到当我尝试从一个Web浏览器的WebHttpBinding服务 连接到我的WCF这个奇怪的错误:

  

Sendera:ActionNotSupportedThe消息动作''不能在接收器进行处理时,由于一个错配ContractFilter在EndpointDispatcher。这可能是因为一个合同不匹配或发送方和接收方之间的结合/安全不匹配(发送者和接收者之间不匹配的操作)。检查发送者和接收者有相同的合同,相同的绑定(包括安全要求,如信息,运输,无)。

我的app.config:

 <服务>
  <服务名称=MyNamespace.MyService>
    <主机>
      < baseAddresses>
        <新增baseAddress =HTTP://本地主机:9091 /为MyService //>
      < / baseAddresses>
    < /主机>
    <端点地址=绑定=的WebHttpBinding合同=MyNamespace.IMyService/>
  < /服务>
< /服务>
 

我的方法只是看起来是这样的:

  [WebGet(UriTemplate =富/ {ID})]
公共字符串的getFoo(串号)
{...
 

解决方案

确定 - 我希望你可能缺少必要的终结点行为 - 尝试此配置:

 <行为>
  < endpointBehaviors>
    <行为NAME =网络>
      < webHttp />
    < /行为>
  < / endpointBehaviors>
< /行为>
<服务>
  <服务名称=MyNamespace.MyService>
    <主机>
      < baseAddresses>
        <新增baseAddress =HTTP://本地主机:9091 /为MyService //>
      < / baseAddresses>
    < /主机>
    <端点
        地址=
        behaviorConfiguration =网
        绑定=的WebHttpBinding
        合同=MyNamespace.IMyService/>
  < /服务>
< /服务>
 
拿下对公司有负面评价的客户,1个月开单100多万

I'm getting this strange error when I try connect to my WCF with webHttpBinding service from a web browser:

Sendera:ActionNotSupportedThe message with Action '' 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).

My app.config:

<services>
  <service name="MyNamespace.MyService">
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:9091/MyService/" />
      </baseAddresses>
    </host>
    <endpoint address="" binding="webHttpBinding" contract="MyNamespace.IMyService" />
  </service>
</services>

My method simply looks like this:

[WebGet(UriTemplate = "foo/{id}")]
public string GetFoo(string id)
{ ...

解决方案

OK - I would expect you're probably missing the endpoint behavior needed - try this config:

<behaviors>
  <endpointBehaviors>
    <behavior name="web">
      <webHttp/>
    </behavior>
  </endpointBehaviors>
</behaviors>    
<services>
  <service name="MyNamespace.MyService">
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:9091/MyService/" />
      </baseAddresses>
    </host>
    <endpoint 
        address="" 
        behaviorConfiguration="web"
        binding="webHttpBinding" 
        contract="MyNamespace.IMyService" />
  </service>
</services>

阅读全文

相关推荐

最新文章