0

i get the following error when trying to start my service:

Could not start the Service: System.InvalidOperationException: This service has multiple endpoints listening at 'https://b2e.my.loc:8093/' which share the same initiating action 'http://localhost:8080/kestrel/AirService'.  As a result, messages with this action would be dropped since the dispatcher would not be able to determine the correct endpoint for handling the message.  Please consider hosting these Endpoints at separate ListenUris.

We got an application that is using a third party WSDL in order to search and book flight.

and we have another winform application that takes the generated reference.cs from the above wsdl

the idea is to create a "simulator" so instead of invoking the real WSDL we are actually invoking the simulator itself and generating the data we need (sort of mocking)

consider the following reference.cs file generated by the WSDL:

namespace FlightWCF
{
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    [System.ServiceModel.ServiceContractAttribute(Namespace = "", ConfigurationName = "FlightWCF.ISearch")]
    public interface ISearch
    {
        [System.ServiceModel.OperationContractAttribute(Action = "http://localhost:8080/kestrel/AirService", ReplyAction = "*")]
        FlightWCF.serviceResponse1 service(FlightWCF.serviceRequest1 request);
    }


    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    [System.ServiceModel.ServiceContractAttribute(Namespace = "", ConfigurationName = "FlightWCF.IReserve")]
    public interface IReserve
    {
        [System.ServiceModel.OperationContractAttribute(Action = "http://localhost:8080/kestrel/AirService", ReplyAction = "*")]
        FlightWCF.serviceResponse6 service(FlightWCF.serviceRequest6 request);
    }   
}

this is part of my app.config

<service name="MyFlightClass.ServiceFlight">
    <endpoint address="" binding="basicHttpBinding"  bindingConfiguration="basicSecureHttpBindingConfiguration" contract="FlightWCF.ISearch" />
    <endpoint address="" binding="basicHttpBinding"  bindingConfiguration="basicSecureHttpBindingConfiguration" contract="FlightWCF.IReserve" />
</service>

and this is the service that is using the above code:

namespace MyFlightClass
{

    class  ServiceFlight :  ISearch, IReserve
    {
        public FlightWCF.serviceResponse1 service(FlightWCF.serviceRequest1 request)
        {
            //DO SOMETHING
        }

        public FlightWCF.serviceResponse6 service(FlightWCF.serviceRequest6 request)
        {
            //DO SOMETHING
        }
    }
}

the problem is that both service uses that same "Action".

if i change the "Action" of one if them, it becomes unreachable.

and i can't find any data on how to configure a service with 2 endpoints that have different contracts but with the same action.

the suggestion "Please consider hosting these Endpoints at separate ListenUris" is unclear to me.

Dardar
  • 624
  • 3
  • 13
  • 30

1 Answers1

0

The main problem is that the double service endpoint address shall not be same. The configuration you provided has the same listening Uri.

<service name="MyFlightClass.ServiceFlight">
    <endpoint address="" binding="basicHttpBinding"  bindingConfiguration="basicSecureHttpBindingConfiguration" contract="FlightWCF.ISearch" />
    <endpoint address="" binding="basicHttpBinding"  bindingConfiguration="basicSecureHttpBindingConfiguration" contract="FlightWCF.IReserve" />
</service>

So it results in that the operation has the same namespace since the operation name is duplicated. But the SOAP message is sent to the right endpoint depending on the soap operation namespace.
In a short, we shall have to change the service endpoint address in the configuration. Feel free to let me know if there is anything I can help with.

Abraham Qian
  • 7,117
  • 1
  • 8
  • 22
  • my application need to only have 1 endpoint (for example https://b2e.my.loc:8093/) and it's dynamic. (i.e every user can define it's own URL to use basically) so is it possible to use a single service (MyFlightClass.ServiceFlight) that defines 2 endpoints with the same address but for different contracts ? – Dardar Apr 16 '19 at 06:24
  • One possibility is to add different listenuris (physical listening addresses) so that the logical addresses on the server side are the same. But when calling, you need to explicitly add a physical address to the endpoint. ClientViaBehavior via = new ClientViaBehavior(new Uri("http://localhost:57749/Service1.svc/efg")); client.Endpoint.EndpointBehaviors.Add(via); var result = client.GetData(34); https://learn.microsoft.com/en-us/dotnet/framework/wcf/samples/multiple-endpoints-at-a-single-listenuri – Abraham Qian Apr 16 '19 at 07:49