none
How to stop exposing multiple endpoint at client side RRS feed

  • Question

  • i like to confess in advance that i am not good in wcf. i was going through a wcf multiple endpoint and saw a single service can have multiple endpoint.

    1) what is the advantage of having multiple endpoint in wcf ?

    2) see the config data and definitely notice that mex end point only used for tcp not for other binding....why?

    3) if service has multiple endpoint then when user add service ref from VS ide then multiple endpoint related data added in config file at client side. can we design service in such a way as a result only one endpoint related address will be revealed at client side. suppose i have one service with http & tcp related endpoint and i want when external customer will add our service from their VS IDE then they will see our http endpoint address not tcp. so guide me how could i do this? how to design service end config file for my requirement?

    4) can we design wcf service this way that i will have one service & one contract but i will have two service tags in config file for single service. suppose one service endpoint will be http and one will be tcp....in this case can we specify same service name & contract name? anyone can give me a sample config entry for my situation coz i like to visualize.

    thanks

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
        <system.serviceModel>
            <behaviors>
                <serviceBehaviors>
                    <behavior name="MulContractService">
                        <serviceMetadata httpGetEnabled="true" />
                    </behavior>
                </serviceBehaviors>
            </behaviors>
            <bindings>
                <basicHttpBinding>
                    <binding name="MulContractBasicBinding" />
                </basicHttpBinding>
                <netTcpBinding>
                    <binding name="MulContractTCPBinding" />
                </netTcpBinding>
                <wsHttpBinding>
                    <binding name="MulContractWsHttpBinding" />
                </wsHttpBinding>
            </bindings>
            <services>
                <service behaviorConfiguration="MulContractService" name="MyWCFLibrary.MultipleContract">
                    <clear />
                    <endpoint binding="basicHttpBinding" bindingConfiguration="MulContractBasicBinding"
                        name="MulContractBasicEndPoint" contract="MyWCFLibrary.IMultipleContract"
                        listenUriMode="Explicit">
                        <identity>
                          <dns value="localhost" />
                            <certificateReference storeName="My" storeLocation="LocalMachine"
                                x509FindType="FindBySubjectDistinguishedName" />
                        </identity>
                    </endpoint>
                    <endpoint address="test1" binding="wsHttpBinding" bindingConfiguration="MulContractWsHttpBinding"
                        name="MulContractWsHttp" contract="MyWCFLibrary.IByeWorld"
                        listenUriMode="Explicit">
                        <identity>
                          <dns value="localhost" />
                            <certificateReference storeName="My" storeLocation="LocalMachine"
                                x509FindType="FindBySubjectDistinguishedName" />
                        </identity>
                    </endpoint>
                    <endpoint address="test1" binding="wsHttpBinding" bindingConfiguration="MulContractWsHttpBinding"
                        name="MulContractWsHttp" contract="MyWCFLibrary.IHelloWorld"
                        listenUriMode="Explicit">
                        <identity>
                          <dns value="localhost" />
                            <certificateReference storeName="My" storeLocation="LocalMachine"
                                x509FindType="FindBySubjectDistinguishedName" />
                        </identity>
                    </endpoint>
                    <endpoint address="net.tcp://localhost:8733/Design_Time_Addresses/MyWCFLibrary/MultipleContract/"
                        binding="netTcpBinding" bindingConfiguration="MulContractTCPBinding"
                        name="MulContractTCPEndPoint" contract="MyWCFLibrary.IMultipleContract" />
                    <host>
                        <baseAddresses>
                            <add baseAddress="http://localhost:8732/Design_Time_Addresses/MyWCFLibrary/MultipleContract/" />
                        </baseAddresses>
                    </host>
                </service>
            </services>
        </system.serviceModel>
    </configuration>


    Tuesday, September 16, 2014 1:03 PM

Answers

  • Hi,

    1) what is the advantage of having multiple endpoint in wcf ?

    The advantage of providing different endpoints is that each endpoint could use different binding. This way based on the client capabilities he could choose the appropriate binding. For example you could expose an interoperable endpoint for Java, PHP, ... clients and a proprietary binary endpoint which could be faster but only for .NET clients.

    Each endpoint has address, binding and contract. So the client could choose which service endpoint he wants to consume.

    2) see the config data and definitely notice that mex end point only used for tcp not for other binding....why?

    There are four types of bindings supported for metadata exchange. They are mexHttpBinding, mexHttpsBinding, mexNamedPipesBinding, mexTcpBinding.

    http://www.wcftutorial.net/Metadata-Exchange-Endpoint.aspx

    3)About Dealing With Multiple EndPoints of a WCF Service, having multiple EndPoints for services are sometimes essential for a good service design. You may want to expose the same service on different EndPoints for Internet users whereas for an Intranet user on a separate EndPoint.

    http://www.c-sharpcorner.com/uploadfile/dhananjaycoder/dealing-multiple-endpoints-of-a-wcf-service499/

    For this situation, I notice that you post all the questions within the same thread. However, we recommended that you could post each issue in single thread so that we can discuss the related issue attentively.

    Regards

    Wednesday, September 17, 2014 5:42 AM
    Moderator