50 votes

AddressFilter mismatch au EndpointDispatcher - le msg avec To

Une idée sur la façon de corriger cela appeler un service via js

Le message avec To 'http://MySite.svc/GetStateXML' ne peut pas être traité par le récepteur, en raison d'une erreur d'AddressFilter dans le EndpointDispatcher. Vérifiez que les EndpointAddresses de l'expéditeur et du destinataire correspondent.

merci

0 votes

Pouvez-vous nous montrer le fichier de configuration du service ?

0voto

Osamah Allaham Points 21

Ajouter webHttp à votre configuration :

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

0voto

Cedric Dumont Points 929

J'ai eu le même genre de problème, juste pour être complet :

  • J'ai utilisé Visual Studio 2017
  • J'avais besoin de créer un service wcf sur une ancienne application utilisant .net 3.5.
  • Il doit être exposé comme un service "soap" et comme un service "Rest".

la configuration que je devais utiliser (pour le reste) était :

il existe une configuration pour le comportement en matière de service et le comportement du point de terminaison

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

0voto

Ziggler Points 105

Dans mon cas, j'ai une application de bibliothèque de service WCF qui est un hôte de service RESTFul et Windows. J'ai eu un problème avec Host App.Config. Veuillez voir ci-dessous

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>

Hôte de service Windows 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>

0voto

Jan Magerl Points 1

Si vous avez plusieurs points de terminaison dans votre WCFService.config comme :

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

Vous devez définir EndpointAddress comme dans votre fichier de configuration. Ensuite, vous avez besoin de ClientViaBehavior pour la 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;

Pour .net core, vous devez écrire le comportement par vous-même :

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)
  {
  }
}

0voto

ikleds Points 1

J'ai eu un problème similaire.

L'adresse suivante a été fournie au client :

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

Mais selon les journaux, le client a envoyé des demandes à l'adresse suivante :

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

Après avoir ajouté l'adresse du point de terminaison dans le fichier de configuration, le service a commencé à fonctionner :

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

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

Prograide.com

Prograide est une communauté de développeurs qui cherche à élargir la connaissance de la programmation au-delà de l'anglais.
Pour cela nous avons les plus grands doutes résolus en français et vous pouvez aussi poser vos propres questions ou résoudre celles des autres.

Powered by:

X