.net 解决 WCF 地址过滤器不匹配中的配置错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/339421/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 10:45:18  来源:igfitidea点击:

Resolving Configuration Error in WCF AddressFilter Mismatch

.netxmlwcf

提问by JoshBerke

I am getting the following error and could use some help resolving it. Anyone have any ideas?

我收到以下错误,可以使用一些帮助来解决它。谁有想法?

The message with To 'http://localhost:60078/BidService.svc/Query' cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher. Check that the sender and receiver's EndpointAddresses agree.

由于 EndpointDispatcher 处的 AddressFilter 不匹配,无法在接收方处理带有 To ' http://localhost:60078/BidService.svc/Query'的消息。检查发送方和接收方的 EndpointAddresses 是否一致。

The client configuration file is:

客户端配置文件为:

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

My Service Contract is:

我的服务合同是:

[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();
}

My Service is configured as follows:

我的服务配置如下:

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

The one thing I read that you need to have the webHttp behavior which I've added. Any help would be appreciated. I just want a simple POX Service

我读到的一件事是您需要具有我添加的 webHttp 行为。任何帮助,将不胜感激。我只想要一个简单的 POX 服务

回答by Brian

I think you need to add the webHttp behavior to the service configuration as well.

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