AddressFilter在EndpointDispatcher上不匹配 - 带有To的消息

时间:2012-02-15 12:50:26

标签: wcf

任何想法我如何纠正这个...通过js调用服务

  

由于EndpointDispatcher上的AddressFilter不匹配,无法在接收方处理带有'http://MySite.svc/GetStateXML'的消息。检查发件人和收件人的EndpointAddresses是否同意

感谢

11 个答案:

答案 0 :(得分:39)

我在讨论Bustamante的学习WCF 一书中的一个例子时也遇到了这个问题。 我曾使用WCF配置编辑器在我的主机上填写我的配置,并将值放在我的端点的名称属性中,而不是地址属性。一旦我修好它就行了起来。 我找到了另一篇建议使用的帖子:

[ServiceBehavior(AddressFilterMode = AddressFilterMode.Any)] 

关于实现类,它起作用但不是根本原因。

底线似乎是:确保您的客户端和服务器配置匹配。

答案 1 :(得分:28)

下面列出的错误表明Web Service实现了WS-Addressing。

"收到To''由于EndpointDispatcher上的AddressFilter不匹配,无法在接收器处理。检查发件人和收件人的EndpointAddresses是否同意"

在SOAP标头中包含以下内容以访问Web服务:

<soap:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
<wsa:To>http://example.com/service</wsa:To>
</soap:Header>

答案 2 :(得分:9)

我在使用webHttpBinding时遇到此错误。

我通过添加

解决了这个问题
<endpointBehaviors>
  <behavior name="EndPointBehavior">
    <enableWebScript/>
  </behavior>
</endpointBehaviors>
<{1>}在<behaviors>下,behaviorConfiguration="EndPointBehavior"设置endpoint binding="webHttpBinding"

完整配置:

<behaviors>
  <serviceBehaviors>
    <behavior name="ServiceBehavior">
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>
  </serviceBehaviors>
  <endpointBehaviors>
    <behavior name="EndPointBehavior">
      <enableWebScript/>
    </behavior>
  </endpointBehaviors>
</behaviors>

<services>
  <service name="WcfService1.Service1" behaviorConfiguration="ServiceBehavior">
    <endpoint address="" 
              binding="webHttpBinding" 
              contract="WcfService1.IService1" 
              behaviorConfiguration="EndPointBehavior">
    </endpoint>
    <endpoint address="mex" 
              binding="mexHttpBinding" 
              contract="IMetadataExchange">
    </endpoint>
  </service>
</services>

答案 3 :(得分:7)

我知道这听起来很愚蠢,但对于有此错误的其他人,请检查您的地址。我们得到了这个错误,因为我们有一个双斜线,其中应该只有一个。

http://localhost//servicename.svc

上述地址导致了这个问题。

http://localhost/servicename.svc

没有表现出问题。

我们从Windows窗体和数据库中读取的部分数据动态创建完整地址。用户输入的是/servicename.svc而不是servicename.svc

答案 4 :(得分:0)

我在开发环境中遇到了IIS中托管的Web服务的问题。通过访问IIS管理器&#39;解决了这个问题。并在错误消息中为主机名添加了绑定。

答案 5 :(得分:0)

webHttp属性添加到您的配置中:

endpointBehaviors
        behavior name ="yourServiceContract"
          webHttp  automaticFormatSelectionEnabled ="true "
        behavior

答案 6 :(得分:0)

我遇到了同样的问题,只是为了完成:

  • 我使用了visual studio 2017
  • 我需要使用.net 3.5
  • 在旧应用程序上创建wcf服务
  • 它应该作为肥皂服务和“休息”服务公开

我需要使用的配置(对于休息部分)是:

服务行为的配置和端点行为

      <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="myServiceBehaviour">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
       </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="webEndpointBehaviour">
          <webHttp />
        </behavior>
      </endpointBehaviors>
    </behaviors>

    <services>
      <service name="My.Service" behaviorConfiguration="myServiceBehaviour">
        <endpoint address="" binding="webHttpBinding" contract="My.IService" behaviorConfiguration="webEndpointBehaviour">
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>
  </system.serviceModel>

答案 7 :(得分:0)

就我而言,我有WCF服务库应用程序,它是RESTFul和Windows服务主机。我对Host App.Config有问题。请看下面

WCF Rest Service App.Config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.web>
    <compilation debug="true" />
  </system.web>
  <!-- When deploying the service library project, the content of the config file must be added to the host's 
  app.config file. System.Configuration does not support config files for libraries. -->
  <system.serviceModel>
    <services>
      <service name="MyService.DocumentWCFRESTService" behaviorConfiguration="defaultServiceBehavior">
        <!-- Service Endpoints -->
        <!-- Unless fully qualified, address is relative to base address supplied above -->
        <endpoint address="http://localhost:2023/DocumentWCFRESTService" 
                  binding="webHttpBinding" behaviorConfiguration="webBehaviorConfiguration"
                  contract="MyService.IDocumentWCFRESTService" >
          <!-- 
              Upon deployment, the following identity element should be removed or replaced to reflect the 
              identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity 
              automatically.
          -->
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <!-- Metadata Endpoints -->
        <!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->
        <!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
        <host>
          <baseAddresses>
            <add baseAddress = "http://localhost:8733/Design_Time_Addresses/Document.Server.WCFREST.Service/DocumentWCFRESTService/" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <serviceHostingEnvironment  multipleSiteBindingsEnabled="true" />
    <bindings> </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="defaultServiceBehavior">
          <!-- To avoid disclosing metadata information, 
          set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="True" httpGetUrl="http://localhost:2023/DocumentWCFRESTService"/>
          <!-- To receive exception details in faults for debugging purposes, 
          set the value below to true.  Set to false before deployment 
          to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="False" />
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="webBehaviorConfiguration">
          <webHttp />
        </behavior>
      </endpointBehaviors>

    </behaviors>
  </system.serviceModel>

</configuration>

Windows Service Host App.Config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

  <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    </startup>

  <system.serviceModel>
    <bindings>
      <webHttpBinding>
        <binding name="webHttpBindingConfiguration" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
                        maxArrayLength="2147483647" maxBytesPerRead="2147483647"
                        maxNameTableCharCount="2147483647" />
        </binding>
      </webHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>       
        <behavior name="documentWCFRESTServiceBehavior">
          <!-- To avoid disclosing metadata information, 
          set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="True" httpGetUrl="http://localhost:2023/DocumentWCFRESTService"/>
          <!-- To receive exception details in faults for debugging purposes, 
          set the value below to true.  Set to false before deployment 
          to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="False" />
        </behavior>               

      </serviceBehaviors>


      <endpointBehaviors>
        <behavior name="webBehaviorConfiguration">
          <webHttp />
        </behavior>
      </endpointBehaviors>
    </behaviors>

    <services>      
      <service name="MyService.DocumentWCFRESTService" behaviorConfiguration="documentWCFRESTServiceBehavior">
        <endpoint address="http://localhost:2023/DocumentWCFRESTService" behaviorConfiguration="webBehaviorConfiguration"
                  binding="webHttpBinding" bindingConfiguration="webHttpBindingConfiguration"
                  contract="MyService.IDocumentWCFRESTService"></endpoint>
      </service>
    </services>

  </system.serviceModel>
</configuration>

答案 8 :(得分:0)

我有类似的问题。

以下地址已提供给客户端:

https://test.mycompany.ru/ChannelService/api/connect.svc

但是根据日志,客户端将请求发送到以下地址:

https://test.mycompany.ru/ChannelService/api/connect.svc/SOAP/Adapter

将端点地址添加到配置文件后,该服务开始工作:

 <services>
      <service name="connect">
        <endpoint address="/SOAP/Adapter"
                  binding="basicHttpBinding"
                  bindingConfiguration="secureHttpBinding"
                  contract="IContract">   
        </endpoint>

        <endpoint address="mex"
                  binding="mexHttpsBinding"
                  contract="IMetadataExchange"/>
      </service>
    </services>

答案 9 :(得分:-1)

查看<webHttp />

<services>
      <service name="SimpleService.SimpleService" behaviorConfiguration="serviceBehaviour">
        <endpoint address="" binding="webHttpBinding" contract="SimpleService.ISimpleService" behaviorConfiguration="web">
        </endpoint>
        <endpoint address="mex"
              binding="mexHttpBinding"
              contract="IMetadataExchange">
        </endpoint>
      </service>
    </services>

....
....

<endpointBehaviors>
        <behavior name="web">
          <webHttp />
        </behavior>
</endpointBehaviors>

答案 10 :(得分:-1)

关键元素是webHttp和binding =&#34; webHttpBinding&#34;对于Json在浏览器测试中的工作。但是,SoapUI仍未能返回JSon。