【问题标题】:Strange error when trying to start my WCF service with webHttpBinding尝试使用 webHttpBinding 启动我的 WCF 服务时出现奇怪的错误
【发布时间】:2011-07-09 20:59:04
【问题描述】:

当我尝试使用 webHttpBinding 服务从网络浏览器连接到我的 WCF 时,我遇到了这个奇怪的错误:

Sendera:ActionNotSupported 由于 EndpointDispatcher 的 ContractFilter 不匹配,接收方无法处理带有 Action '' 的消息。这可能是因为合约不匹配(发送方和接收方之间的操作不匹配)或发送方和接收方之间的绑定/安全不匹配。检查发送方和接收方是否具有相同的合同和相同的绑定(包括安全要求,例如消息、传输、无)。

我的 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>

我的方法看起来像这样:

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

【问题讨论】:

    标签: c# .net wcf


    【解决方案1】:

    当您将方法从 GetFoo(string fooID) 更新为 GetFoo(string id) 时,您是否也使用更新后的参数名称 id 更新了 IMyService 中的合约?

    您上一个问题的参考:Is there a way to have custom defined friendly URLs with WCF without IIS?

    【讨论】:

    • 这实际上不是我遇到的问题,我只是在发布问题时输入了错误的问题。
    【解决方案2】:

    好的 - 我希望您可能缺少所需的端点行为 - 试试这个配置:

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

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-07
    • 2020-12-27
    • 2019-12-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多