Sunday, July 3, 2011

Enable Https for WCF

To enable Https for WCF, you need to change the config in the service site. For host in IIS, you need to make sure do not assign the name to bindings/[binding type]/binding and do not assign binding name in services/service/endpoint. Below is the sample:

<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="HttpsBehavior" >
<serviceMetadata httpsGetEnabled="true" httpGetEnabled="true" policyVersion="Policy12"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="TestService" behaviorConfiguration="HttpsBehavior" >
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
<endpoint
address=""
binding="basicHttpBinding" "No Bindding Name here"
contract="mProductive.PortalAdmin.WebSite.IWebPurchase"
/>
</service>
</services>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" >
<baseAddressPrefixFilters>
<add prefix="http://localhost/"/>
</baseAddressPrefixFilters>
</serviceHostingEnvironment>
<bindings >
<basicHttpBinding>
<binding "No Bindding Name here">
<security mode="Transport">
<transport clientCredentialType="None"/></security>
</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>