Search code examples
wcfweb-configsvc

Using 2 WCF interfaces in the same svc file


We are trying to communicate with an external WCF service.

The WCF services are exposed via svc files. It appears that there are 2 interfaces exposed via the same svc file.

How can we configure this in the web.config file?


Solution

  • If I understand your question correctly, you have a single class that implements 2 WCF service contracts. In your web.config, you configure an endpoint for each service contract, but under the same <service> node. I've only done this when self-hosting WCF services, not in IIS, but I think if you specify a value for address in your endpoint configuration, it will make it relative to the location of the .svc file:

    <service name="YourServiceLibrary.YourServiceClass">
      <endpoint address="Service1"
        contract="YourServiceLibrary.IService1"
        ...
         />
      <endpoint address="Service2"
        contract="YourServiceLibrary.IService2"
        ...
         />
    </service>
    

    You would then setup your client proxies for each service contract to point to http://YourServer/YourServicePath/YourServiceClass.svc/Service1 and http://YourServer/YourServicePath/YourServiceClass.svc/Service2