Can't access WCF service after versioning service contracts

I'm having trouble figuring out an issue with a WCF service that came up after I applied the "v2" contract to it to extend functionality. Everything builds fine, but when I try to access the service in the browser, I am simply told that it cannot connect. When I try to add it as a service reference, I get a similar message about connection problems. However, when I remove the extended contract endpoint from the config file and leave the old "v1" version intact, it works fine.

Here is the "v1" contract:

namespace Company.Services.Ticketing.Retail.Contracts
{
    [ServiceContract(Name = "OutletReportingContract_v1", Namespace = "https://enterprise.company.ie/Services/Retail")]
    public interface IOutletReportingContract_v1
    {
        /* methods */
    }
}

      

And here is the "v2" contract:

namespace Company.Services.Ticketing.Retail.Contracts
{
    [ServiceContract(Name = "OutletReportingContract_v2", Namespace = "https://enterprise.company.ie/Services/Retail")]
    public interface IOutletReportingContract_v2 : IOutletReportingContract_v1
    {
        /* methods */
    }
}

      

Here are the endpoints in the Web.config:

  <service name="Company.Services.Ticketing.Retail.OutletService" behaviorConfiguration="Public">
    <endpoint address="1" binding="wsHttpBinding" bindingConfiguration="Standard" name="OutletReportingContract_v1" 
        contract="Company.Services.Ticketing.Retail.Contracts.IOutletReportingContract_v1" />
    <endpoint address="2" binding="wsHttpBinding" bindingConfiguration="Standard" name="OutletReportingContract_v2" 
        contract="Company.Services.Ticketing.Retail.Contracts.IOutletReportingContract_v2" />
    <endpoint address="mex" binding="mexHttpsBinding" name="IMetadataExchange" contract="IMetadataExchange" />
  </service>

      

And here is the error message that appears in the event viewer:

WebHost was unable to process the request. Sender info: System.ServiceModel.Activation.HostedHttpRequestAsyncResult / 28075619 Exception: System.Web.HttpException (0x80004005): There was no channel actively listening at ' https: //phil-pc.company.local/Services/Retail/OutletService /_vti_bin/ListData.svc/ $ metadata '. This is often caused by an invalid URI. Make sure that the address to which the message is sent matches the address where the service is listening. ---> System.ServiceModel.EndpointNotFoundException: There was no channel actively listening ' https: //phil-pc.company.local/Services/Retail/OutletService.svc/_vti_bin/ListData.svc/$ metadata '. This is often caused by an invalid URI. Make sure that the address to which the message is sent matches the address where the service is listening. in System.ServiceModel.Activation.HostedHttpTransportManager.HttpContextReceived (result HostedHttpRequestAsyncResult) in System.ServiceModel.Activation.HostedHttpRequestAsyncResult.HandleRequest () in System.ServiceModel.Activation.HostedHttpRequestAsyncResult.BeginRequest () in System.Runtime.AsyncResult.End [TAsyncResult] ( result IAsyncResult) in System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End (result IAsyncResult) Process name: w3wp Process id: 8148

I looked down a bit and would be grateful for any help :)

+3


source to share


1 answer


You need to separate the declaration of your services in the web.config.

Assuming your implementation classes are named OutletService_v1 and OutletService_v2, you should get something like this:



<services>
  <service name="Company.Services.Ticketing.Retail.OutletService_v1" behaviorConfiguration="Public">
    <endpoint binding="wsHttpBinding" bindingConfiguration="Standard" contract="Company.Services.Ticketing.Retail.Contracts.IOutletReportingContract_v1" />
    <endpoint address="mex" binding="mexHttpsBinding" name="IMetadataExchange" contract="IMetadataExchange" />
  </service>

  <service name="Company.Services.Ticketing.Retail.OutletService_v2" behaviorConfiguration="Public">
    <endpoint binding="wsHttpBinding" bindingConfiguration="Standard" contract="Company.Services.Ticketing.Retail.Contracts.IOutletReportingContract_v2" />
    <endpoint address="mex" binding="mexHttpsBinding" name="IMetadataExchange" contract="IMetadataExchange" />
  </service>
</services>
      

Run codeHide result


0


source







All Articles