解决WCF AddressFilter不匹配的配置错误

18
我遇到以下错误,需要帮助解决。有人有什么想法吗?
发送 To 'http://localhost:60078/BidService.svc/Query' 的消息无法在接收端处理,因为 EndpointDispatcher 中存在 AddressFilter 不匹配。请检查发送方和接收方的 EndpointAddresses 是否一致。
客户端配置文件如下:
<system.serviceModel>
    <bindings>
        <customBinding>
            <binding name="WebHttpBinding_IBidService">
                <textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
                    messageVersion="None" writeEncoding="utf-8">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" 
                                  maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                </textMessageEncoding>
                    <httpTransport manualAddressing="True" />
            </binding>
        </customBinding>
    </bindings>
    <client>
        <endpoint binding="customBinding" bindingConfiguration="WebHttpBinding_IBidService" 
                  behaviorConfiguration="IBidServiceBehavior"
            contract="myService.IBidService" name="WebHttpBinding_IBidService" />
    </client>
        <behaviors>
            <endpointBehaviors>
                <behavior name="IBidServiceBehavior">
                    <webHttp/>
                </behavior>
            </endpointBehaviors>
        </behaviors>
</system.serviceModel>

我的服务合同是:

[ServiceContract(Namespace = "http://xxxx.com/services/bids")]
public interface IBidService
{
    [OperationContract(Action = "*")]
    [WebGet(RequestFormat = WebMessageFormat.Xml, ResponseFormat = WebMessageFormat.Xml, BodyStyle = WebMessageBodyStyle.Wrapped)]
    List<BidSummary> Query();
}

我的服务配置如下:

<service name="xxx.Web.Services.Bids.BidService" 
          behaviorConfiguration="Cutter.Web.Services.Bids.BidServiceBehavior">
   <endpoint address="" binding="basicHttpBinding" 
             contract="xxx.Web.Services.Bids.IBidService" />                
   <endpoint address="mex" binding="mexHttpBinding" 
             contract="IMetadataExchange" />
</service>

<behavior name="Cutter.Web.Services.Bids.BidServiceBehavior">
   <serviceMetadata httpGetEnabled="true"  />
   <serviceDebug includeExceptionDetailInFaults="true" />
</behavior>

我读到需要添加webHttp行为。能提供任何帮助将不胜感激。我只想要一个简单的POX服务。

1个回答

31

我认为您需要在服务配置中添加webHttp行为。


我也这么想,但我认为这不是一个选项。至少在智能感知中没有显示出来。 - JoshBerke
2
谢谢,我不明白为什么它们有ServiceBehaviors和EndpointBehaviors,但现在它能够工作了...现在让我来让我的WCF客户端工作起来。 - JoshBerke
4
一个服务可以有多个端点;有些行为范围覆盖整个服务,而另一些则基于每个端点进行操作。 - Brian
1
如果您使用 [WebInvoke] 装饰 ServiceContract,则需要在行为配置中声明 <webHttp /> 行为。 - Raffaeu

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接