Home > CodeProject, WCF > WCF over HTTPS

WCF over HTTPS

I have been working on a WCF web service that I finally deployed to our staging server which runs over HTTPS. Everything seemed fine. I was able to hit it and generate the WSDL. However, when I tried running the svcutil.exe on it, I got the following error:

Error: Cannot add the transport element 'httpTransport'. Another transport eleme
nt already exists in the binding 'System.ServiceModel.Configuration.HttpTranspor
tElement, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=
b77a5c561934e089'. There can only be one transport element for each binding.

Upon investigation, I realized that when deploying a WCF web service over HTTPS, you must set the ‘Security’ mode to ‘Transport.’. Below are the steps to do this:

1. Add the following inside the section:

<bindings>
  <wsHttpBinding>
     <binding name="webBinding">
       <security mode="Transport"></security>
     </binding>
  </wsHttpBinding>
</bindings>

2. Add the following attribute to the element:

bindingConfiguration="webBinding"

That should be all.

Below is a sample section:

<system.serviceModel>
  <services>
    <service name="MyWebService"
        behaviorConfiguration="ServiceBehavior">
	<!-- Service Endpoints -->
	<endpoint address="" binding="wsHttpBinding"
           bindingConfiguration="webBinding" contract="IMyWebService">
	</endpoint>
       <endpoint address="mex" binding="mexHttpBinding" 
         contract="IMetadataExchange" />
   </service>
</services>
<bindings>
  <wsHttpBinding>
     <binding name="webBinding">
       <security mode="Transport" />
     </binding>
  </wsHttpBinding>
</bindings>
<behaviors>
  <serviceBehaviors>
    <behavior name="ServiceBehavior">
      <serviceMetadata httpGetEnabled="true"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
</system.serviceModel>

Post to Twitter Post to Yahoo Buzz Post to Delicious Post to Digg Post to Facebook Post to Reddit Reddit Post to StumbleUpon

  1. No comments yet.
  1. No trackbacks yet.

Spam Protection by WP-SpamFree Plugin

Bad Behavior has blocked 249 access attempts in the last 7 days.