How to Configure Multiple Bindings in WCF

How to configure multiple bindings in WCF

Suppose our client have multiple applications like windows and web application. Now we want to expose same service to the multiple applications, so we need to configure multiple binding in web.config file. BasicHttpBinding for web application and netTcpBinding for windows application. Remember we can not use netTcpBinding for web application. Here we use the mexHttpBinding binding for both applications. mexHttpBinding binding is used to expose the metadata to client side. If we did not put it in web.config file it show an error (Only VS 2010 and below).

<services>

      <service behaviorConfiguration="ServiceBehavior" name="Service">

        <endpoint address="Web1"

                  binding ="basicHttpBinding"

                  contract ="IService">

          <identity>

            <dns value= "amit-pc"/>

          </identity>

        </endpoint>

        <endpoint address="Web"

                 binding ="mexHttpBinding"

                 contract ="IMetadataExchange">

        </endpoint>

       

        <endpoint address=""

                binding ="netTcpBinding"

                contract ="IService" bindingConfiguration="InsecureTcp">

        </endpoint>

        <endpoint address="Windows"

                  binding ="mexTcpBinding"

                  contract ="IMetadataExchange">         

        </endpoint>    

      </service>

    </services>

Ebook Download
View all
Learn
View all