Thursday, August 16, 2012

WCF : http vs https configuration

http vs https configuration

HTTP Web.config settings.

<system.serviceModel>
    <services>
      <service name="MyService.ServiceImplementation.MyServiceCall" behaviorConfiguration="MyService.ServiceImplementation.MyServiceCall_Behavior">
        <!-- Service Endpoints -->
          <endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicHttpBindingConfig" contract="MyService.ServiceContract.IMyService" bindingNamespace="http://www.MyService.com/">
          <!--
          <endpoint address="" binding="basicHttpBinding" contract="MyService.ServiceContract.IMyService" bindingNamespace="http://www.MyService.com/">
              Upon deployment, the following identity element should be removed or replaced to reflect the
              identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity
              automatically.
          -->
                    <identity>
                        <dns value="localhost"/>
                    </identity>
                </endpoint>
                <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
            </service>
        </services>
        <bindings>
        <wsHttpBinding>
            <binding name="wsHttpBinding" closeTimeout="00:20:00" openTimeout="00:20:00" receiveTimeout="00:20:00" sendTimeout="00:20:00" messageEncoding="Mtom">
                <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
                <!--<httpTransport maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" authenticationScheme="Anonymous" maxBufferSize="2147483647" transferMode="Buffered"/>-->
            </binding>
           
        </wsHttpBinding>
            <basicHttpBinding>
                <binding name="basicHttpBindingConfig" closeTimeout="00:20:00" openTimeout="00:20:00" receiveTimeout="00:20:00" sendTimeout="00:20:00" transferMode="StreamedResponse" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" >
                    <readerQuotas  maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
                    <!--<httpTransport maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"  maxBufferSize="2147483647" transferMode="StreamedResponse"/>-->
                </binding>
            </basicHttpBinding>
        </bindings>
     
        <behaviors>
            <serviceBehaviors>
                <behavior name="MyService.ServiceImplementation.MyServiceCall_Behavior">
                    <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
                    <serviceMetadata httpGetEnabled="true"/>
                    <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
                    <serviceDebug includeExceptionDetailInFaults="true"/>
                </behavior>
            </serviceBehaviors>
        </behaviors>
    </system.serviceModel>


HTTPS Web.config settings.


 <system.serviceModel>
    <!-- We have multiple host headers on our server -->
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true">
    </serviceHostingEnvironment>
  
<bindings>
      <basicHttpBinding>
        <binding name="SecureTransport" >
          <security mode="Transport">
            <transport clientCredentialType="None"/>
          </security>
        </binding>

   
    <binding name="basicHttpBindingConfigMTOM" closeTimeout="00:20:00" openTimeout="00:20:00" receiveTimeout="00:20:00" sendTimeout="00:20:00" messageEncoding="Mtom" >
<security mode="Transport">
            <transport clientCredentialType="None"/>
          </security>

        <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
    </binding>
    <binding name="basicHttpBindingConfigTEXT" closeTimeout="00:20:00" openTimeout="00:20:00" receiveTimeout="00:20:00" sendTimeout="00:20:00" messageEncoding="Text" transferMode="StreamedResponse">
<security mode="Transport">
            <transport clientCredentialType="None"/>
          </security>
        <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>               
    </binding>
      </basicHttpBinding>
    </bindings>


    <services>
      <service name="MyService.ServiceImplementation.MyServiceCall" behaviorConfiguration="MyService.ServiceImplementation.MyServiceCall_Behavior">
        <!-- Service Endpoints -->

        <endpoint address="" bindingConfiguration="basicHttpBindingConfigMTOM" binding="basicHttpBinding" contract="MyService.ServiceContract.IMyService" bindingNamespace="http://www.MyService.com" >

          <!--<endpoint address="Reporting/MyService.svc" binding="basicHttpBinding" contract="MyService.ServiceContract.IMyService">
Make the endpoint relative
                -->

          <!--
              Upon deployment, the following identity element should be removed or replaced to reflect the
              identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity
              automatically.
          -->
          <identity>

            <dns value="test.MyService.com" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>


    <behaviors>
      <serviceBehaviors>
        <behavior name="MyService.ServiceImplementation.MyServiceCall_Behavior">
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="false" httpsGetEnabled="True" httpsGetUrl=""/>
          <!-- To receive exception  details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>

  </system.serviceModel>