Search code examples
c#wcfwcf-binding

WCF endpoint configuration: 2nd endpoint doesn't work at all, 1st endpoint doesn't seem affected by binding


In a WCF service hosted in IIS, I'm trying to set up multiple endpoints. One for SOAP and one for SOAP12. Per the MSDN documentation, I've edited Web.config like:

<services>
  <service name="MyNamespace.MyClass">
    <endpoint address="" binding="basicHttpBinding" contract="IContract" />
    <endpoint address="Endpoint2" binding="wsHttpBinding" contract="IContract" />
  </service>
</services>

This doesn't seem to have any effect. There is no answer on URL:

http://localhost:51454/MyClass.svc/Endpoint2

If I change IContract to IContract2, I get the error:

The service '/MyClass.svc' cannot be activated due to an exception during 
compilation.

So the Web.config I'm editing is the one being used.

Changing the binding for the default address from basicHttpBinding to wsHttpBinding doesn't have any effect. The WSDL stays the same.

The WSDL includes this bit, which seems to suggest that it's running using a generated binding:

<wsdl:service name="TapasSim">
    <wsdl:port name="BasicHttpBinding_IContract" 
               binding="i0:BasicHttpBinding_IContract">
        <soap:address location="http://localhost:51454/MyClass.svc"/>
    </wsdl:port>
</wsdl:service>

Why does the WCF service not use the configuration from Web.config?
Why does WCF not listen on /Endpoint2 with the SOAP12 binding?
Why does the default endpoint not change from basicHttpBinding to wsHttpBinding?


Solution

  • The problem was the service name:

    <service name="MyNamespace.MyClass">
    

    The class name was wrong. When you enter a wrong contract interface, WCF throws an error. But a wrong class name is silently ignored. That explains why it fell back on the default configuration.