tags:

views:

21

answers:

1

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?

+2  A: 

If you have one service (I assume you mean one service contract), and you want to expose two endpoints, then your option #2 should be the one to use.

However, I do see a few issues with your config:

<service name="MyWcfService.MyService"
         behaviorConfiguration="MyWcfService.HttpBehavior">

What does that "MyWcfService.HttpBehavior" include?? Anything that could cause trouble with net.Tcp endpoints??

<endpoint name="ApplicationHttp"
          address="http://localhost:8731/MyWcfService/Application"
          binding="basicHttpBinding"
          bindingConfiguration="HttpBinding"
          contract="MyWcfService.Interfaces.IMyService" />

<endpoint name="Application"
          address="net.tcp://localhost:49153/MyWcfService/Application"
          binding="netTcpBinding"
          bindingConfiguration="SecuredByWindows"
          contract="EmsHistorianService.Interfaces.IApplicationHistorianService" />

If you have one service - one service contract - then the contract= attribute of both application endpoints must be the same.

Either it's the first one (contract="MyWcfService.Interfaces.IMyService") or the second one (contract="EmsHistorianService.Interfaces.IApplicationHistorianService") - I cannto know - but it should be the same for both <endpoint> entries, for sure.

UPDATE:
@Sean: you might be misunderstanding the MEX mechanism: the tcpMexBinding will not show just netTcp bindings - and that's totally by design and intended. The MEX bindings are a mechanism so you can get metadata about the service and all its endpoints. Of course, both MEX endpoints will show all the application endpoints - that's their whole purpose in life. MEX endpoints give an inquiring client the (complete and unfiltered) metadata about the service. It's up to the client to then decide which endpoint he can and wants to conenct to.

marc_s
Thanks Marc, I am working through your suggestions, and I have made it farther. Right now my behavior is very vanilla, as for the contract difference, I was trying to make the names more generic for the example, and missed one. I now have the opposite issue. Now my problem is both sets of endpoints (http and tcp) are showing up in each mex listing. I need to filter down the list.
Sean
@Sean:updated my answer with some additional info on MEX
marc_s
I see: Thanks so much!
Sean