WCF service with 2 Bindings and 2 Base Addresses

Posted by Sean on Stack Overflow See other posts from Stack Overflow or by Sean
Published on 2010-05-12T20:52:19Z Indexed on 2010/05/12 20:54 UTC
Read the original article Hit count: 339

Filed under:
|

I have written a WCF service (I am a newb) that I want to provide 2 endpoints for (net.tcp & basicHttp) The problem comes when I try to configure the endpoints. If I configure them as seperate services, then my service names are the same which causes a problem. I have seen recomended creating shim classes (classA : MyService, and ClassB : MyService) but that seems smelly.

        <services>
        <service name="MyWcfService.MyService"
                         behaviorConfiguration="MyWcfService.HttpBehavior">
            <endpoint name="ApplicationHttp"
                                address="Application"
                                binding="basicHttpBinding"
                                bindingConfiguration="HttpBinding"
                                contract="MyWcfService.Interfaces.IMyService" />
            <endpoint address="mex"
                                binding="mexHttpBinding"
                                contract="IMetadataExchange" />
            <host>
                <baseAddresses>
                    <add baseAddress="http://localhost:8731/MyWcfService/" />
                </baseAddresses>
            </host>
        </service>
        <service name="MyWcfService.MyService"
                         behaviorConfiguration="MyWcfService.MyBehavior">
            <endpoint name="Application"
                                address="Application"
                                binding="netTcpBinding"
                                bindingConfiguration="SecuredByWindows"
                                contract="EmsHistorianService.Interfaces.IApplicationHistorianService" />
            <endpoint address="mex"
                                binding="mexTcpBinding"
                                contract="IMetadataExchange" />
            <host>
                <baseAddresses>
                    <add baseAddress="net.tcp://localhost:49153/MyWcfService" />
                </baseAddresses>
            </host>
        </service>
    </services>

I have tried using a single service with the base address integrated into the address, but that gives me errors as well

        <services>
        <service name="MyWcfService.MyService"
                         behaviorConfiguration="MyWcfService.HttpBehavior">
            <endpoint name="ApplicationHttp"
                                address="http://localhost:8731/MyWcfService/Application"
                                binding="basicHttpBinding"
                                bindingConfiguration="HttpBinding"
                                contract="MyWcfService.Interfaces.IMyService" />
            <endpoint address="http://localhost:8731/MyWcfService/mex"
                                binding="mexHttpBinding"
                                contract="IMetadataExchange" />
            <endpoint name="Application"
                                address="net.tcp://localhost:49153/MyWcfService/Application"
                                binding="netTcpBinding"
                                bindingConfiguration="SecuredByWindows"
                                contract="EmsHistorianService.Interfaces.IApplicationHistorianService" />
            <endpoint address="net.tcp://localhost:49153/MyWcfService/mex"
                                binding="mexTcpBinding"
                                contract="IMetadataExchange" />
        </service>
    </services>

Any ideas?

© Stack Overflow or respective owner

Related posts about .NET

Related posts about wcf