Friday, May 25, 2012

Configuring a client to request wcf service using Http and https protocols.

At a time we can request one WCF service using one protocol only. If you want to use both the protocols at a time there should be a difference in your service address. Below code I commented the HTTPS protocol accessing. Once you comment the http and uncomment the https it will start using https protocol for your requests.


<system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <!-- Https(SSL) Binding -->
        <!--<binding name="BasicHttpBinding_Service"
          messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true">         
          <security mode="Transport">
            <transport clientCredentialType="None"/>          
          </security>
        </binding>-->
        <!-- Http binding-->
        <!-- please comment below lines if client want to use HTTPS protocol-->
        <binding name="BasicHttpBinding_Service"
          messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true">         
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <!-- Https(SSL) End point-->
      <!--<endpoint address="your service url"
       binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_Service"
       contract="ServiceReference.IService" name="BasicHttpBinding_Service" />-->

      <!--Http end point-->
      <!-- please comment below lines if user want to use Https as communication protocol-->
      <endpoint address="your service url"
      binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_Service"
      contract="ServiceReference.IService" name="BasicHttpBinding_Service" />
    </client>
  </system.serviceModel>

No comments:

Post a Comment