当试图用的WebHttpBinding开始我的WCF服务奇怪的错误 [英] Strange error when trying to start my WCF service with webHttpBinding

查看:262
本文介绍了当试图用的WebHttpBinding开始我的WCF服务奇怪的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到当我尝试从一个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/>
  < /服务>
< /服务>
 

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>

这篇关于当试图用的WebHttpBinding开始我的WCF服务奇怪的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆