WCF (REST) multiple host headers with one endpoint

Posted by Maan on Stack Overflow See other posts from Stack Overflow or by Maan
Published on 2010-06-03T10:11:17Z Indexed on 2010/06/03 10:14 UTC
Read the original article Hit count: 374

Filed under:
|
|
|
|

I have an issue with a WCF REST service (.NET 4) which has multiple host headers, but one end point. The host headers are for example:
xxx.yyy.net
xxx.yyy.com

Both host headers are configured in IIS over HTTPS and redirect to the same WCF service endpoint. I have an Error Handling behavior which logs some extra information in case of an error.

The problem is that the logging behavior only works for one of both URLs. When I first call the .net URL, the logging is only working for requests on the .net URL. When I first call the .com URL (after a Worker Process recycle), it’s only working on requests on the .com URL.

The configuration looks like this:

<system.serviceModel>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
        <services>
            <service name="XXX.RemoteHostService">
                <endpoint address="" behaviorConfiguration="RemoteHostEndPointBehavior" binding="webHttpBinding" bindingConfiguration="HTTPSTransport" contract="XXX.IRemoteHostService" />
            </service>
        </services>
        <extensions>
            <behaviorExtensions>
                <add name="errorHandling" type="XXX.ErrorHandling.ErrorHandlerBehavior, XXX.Services, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
                </behaviorExtensions>
        </extensions>
        <bindings>
            <webHttpBinding>
                <binding name="HTTPSTransport">
                    <security mode="Transport">
                        <transport clientCredentialType="None"/>
                    </security>
                </binding>
            </webHttpBinding>
        </bindings>
        <behaviors>
            <endpointBehaviors>
                <behavior name="RemoteHostEndPointBehavior">
                    <webHttp />
                    <errorHandling />
                </behavior>
            </endpointBehaviors>
        </behaviors>
….

Should I configure multiple endpoints? Or in which way could I configure the WCF Service so the logging behavior is working for both URLs?

I tried several things, also solutions mentioned earlier on StackOverflow. But no luck until now...

© Stack Overflow or respective owner

Related posts about wcf

Related posts about rest