AddressFilter mismatch at the EndpointDispatcher - the msg with To

前端 未结 12 1810
一个人的身影
一个人的身影 2020-12-14 06:21

Any ideas how I correct this.. calling a service via js

The message with To \'http://MySite.svc/GetStateXML\' cannot be processed at the receiver, due

相关标签:
12条回答
  • 2020-12-14 06:40

    if you have multiple endpoints in your WCFService.config like:

    <endpoint address="urn:Service.Test" .../>
    <endpoint address="urn:Service.Test2".../>
    <host>
      <baseAddresses>
        <add baseAddress="net.tcp://localhost:1234/Service/" />
        <add baseAddress="http://localhost:1233/Service/" />
        <add baseAddress="net.pipe://localhost/Service/" />
      </baseAddresses>
    </host>
    

    You need to set EndpointAddress like in your config file. Then you need ClientViaBehavior for the baseAddress.

    NetTcpBinding binding = new NetTcpBinding(SecurityMode.None);
    EndpointAddress address = new EndpointAddress("urn:Service.Test");
    AndonClient client = new AndonClient(binding, address);
    client.ChannelFactory.Endpoint.EndpointBehaviors.Add(new ClientViaBehavior(new Uri("net.tcp://localhost:1234/Service/Test")));
    var response = client.GetDataAsync().Result;
    

    For .net core you need to write the Behavior by yourself:

    public class ClientViaBehavior : IEndpointBehavior
    {
      Uri uri;
    
      public ClientViaBehavior(Uri uri)
      {
        if (uri == null)
          throw new ArgumentNullException(nameof(uri));
    
        this.uri = uri;
      }
    
      public Uri Uri
      {
        get { return this.uri; }
        set
        {
          if (value == null)
            throw new ArgumentNullException(nameof(value));
    
          this.uri = value;
        }
      }
    
      public void AddBindingParameters(ServiceEndpoint endpoint, BindingParameterCollection bindingParameters)
      {
      }
    
      public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)
      {
        if (clientRuntime == null)
        {
          throw new ArgumentNullException(nameof(clientRuntime));
        }
        clientRuntime.Via = this.Uri;
      }
    
      public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
      {
        throw new NotImplementedException();
      }
    
      void IEndpointBehavior.Validate(ServiceEndpoint serviceEndpoint)
      {
      }
    }
    
    0 讨论(0)
  • 2020-12-14 06:41

    The error listed below indicates that the Web Service implements WS-Addressing.

    "The message with To '' cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher. Check that the sender and receiver's EndpointAddresses agree"

    Include the following in your SOAP Headers to access the Web Service:

    <soap:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
    <wsa:To>http://example.com/service</wsa:To>
    </soap:Header>
    
    0 讨论(0)
  • 2020-12-14 06:44

    I had a similar problem.

    The following address was provided to the client:

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

    But according to the logs, the client sent requests to the following address:

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

    After I added the endpoint address to the configuration file, the service started working:

     <services>
          <service name="connect">
            <endpoint address="/SOAP/Adapter"
                      binding="basicHttpBinding"
                      bindingConfiguration="secureHttpBinding"
                      contract="IContract">   
            </endpoint>
    
            <endpoint address="mex"
                      binding="mexHttpsBinding"
                      contract="IMetadataExchange"/>
          </service>
        </services>
    
    0 讨论(0)
  • 2020-12-14 06:47

    In my case I have WCF Service library application which is a RESTFul and Windows Service Host. I had problem with Host App.Config. Please see below

    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>
    
    0 讨论(0)
  • 2020-12-14 06:51

    I got this error while I was using webHttpBinding.

    I resolved it by adding

    <endpointBehaviors>
      <behavior name="EndPointBehavior">
        <enableWebScript/>
      </behavior>
    </endpointBehaviors>
    

    under <behaviors> and setting behaviorConfiguration="EndPointBehavior" in my endpoint with binding="webHttpBinding".

    Full config:

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

    0 讨论(0)
  • 2020-12-14 06:51

    I had the same kind of issue, just to be complete :

    • I used visual studio 2017
    • I needed to create a wcf service on an old application using .net 3.5
    • It should be exposed as a soap service and as a "Rest" service

    the configuration that I needed to use (for rest part) was :

    there is a config for the service behaviour and the endpoint behaviour

          <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>
    
    0 讨论(0)
提交回复
热议问题