Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTTPS on basicHttpBinding for WCF Service

I am using IIS 7. HTTPS binding is enabled on it with port number 443. I have a WCF service as an application under the website. I am trying to introduce HTTPS security to service (with basicHttpBinding) based on http://msdn.microsoft.com/en-us/library/ms729700.aspx

I am getting the following error – “The provided URI scheme 'https' is invalid; expected 'http'.”. When I checked the event log it has the stack trace as follows:

Stack Trace :    at System.ServiceModel.Channels.TransportChannelFactory`1.ValidateScheme(Uri via)

at System.ServiceModel.Channels.HttpChannelFactory.ValidateCreateChannelParameters(EndpointAddress remoteAddress, Uri via)

What is the change required to make it working on HTTPS with basicHttpBinding?

Note: Certificate is created using "Create Self Signed Certificate" in IIS 7.

 <system.serviceModel>

  <behaviors>
<serviceBehaviors>
  <behavior name="serviceFaultBehavior">
    <serviceMetadata httpGetEnabled="true" />
    <serviceDebug includeExceptionDetailInFaults="true"/>
  </behavior>
</serviceBehaviors>
  </behaviors>

  <services>
<service name="Business.TV.Clearance.Services.ServiceHandler"
         behaviorConfiguration="serviceFaultBehavior">
  <endpoint address=""
            binding="basicHttpBinding"
            contract="Business.TV.Clearance.Services.IServiceHandler"
            bindingConfiguration="httpBinding">
    <identity>
      <dns value="localhost" />
    </identity>
  </endpoint>
</service>

  <bindings>
<basicHttpBinding>

  <binding name="httpBinding"
           maxReceivedMessageSize="2000000"
           maxBufferSize="2000000">

    <security mode="Transport">
      <transport clientCredentialType="Windows" />
    </security>


    <readerQuotas maxDepth="2147483647"
                  maxStringContentLength="2147483647"
                  maxArrayLength="2147483647" />
  </binding>
</basicHttpBinding>
  </bindings>

   <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

   <extensions>
 <behaviorExtensions>
  <add name="serviceFaultBehavior"
type="Business.TV.Clearance.Services.ServiceFaultBehaviorExtensionElement,Business.TV.Clearance.Services, Version=1.0.0.0, Culture=neutral"/>
</behaviorExtensions>
  </extensions>

</system.serviceModel>
like image 593
LCJ Avatar asked Dec 01 '11 07:12

LCJ


People also ask

What is BasicHttpBinding in WCF?

BasicHttpBinding is suitable for communicating with ASP.NET Web Service (ASMX) based services that conform to the WS-Basic Profile that conforms with Web Services. This binding uses HTTP as the transport and text/XML as the default message encoding. Security is disabled by default.

How can I combine the WCF services config for both HTTP and https in one web config?

You need to enable both HTTP & HTTPS in IIS. In IIS 7.5, go to your site and click on Bindings under Edit Site Action. Ensure that both http & https have been added. Then you need to create a binding for HTTP under <basicHttpBinding> , with security mode set to none.

What is difference between WsHttpBinding and BasicHttpBinding?

Primarily BasicHttpBinding is designed to exchange SOAP over HTTP(s) only, just like old ASMX or . net web services and supports the WS-I BasicProfile. WsHttpBinding supports the advanced WS-* specification which includes WS-Addressing and WS-Security etc.


1 Answers

You need to change:

<serviceMetadata httpGetEnabled="true" />

to:

<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
like image 142
competent_tech Avatar answered Sep 22 '22 15:09

competent_tech