Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get WCF Service Running over SSL?

I'm running a C# web service in IIS6 and trying to get it to work over SSL. When doing a tcpdump it shows the initial call as https but every other call over http. My SSL certificate is self signed and https works fine in my web browser. I'm using PHP SoapClient for the client.

Does anyone know what would cause this?

In the wsdl the address location is set to http. Should this be https? How do I change it?

<wsdl:service name="Service">
<wsdl:port name="BasicHttpBinding_Service" binding="i0:BasicHttpBinding_Service">
<soap:address location="http://example.com/Service.svc"/>
</wsdl:port>
</wsdl:service>
like image 976
Eggo Avatar asked Apr 27 '11 23:04

Eggo


People also ask

How do I run a WCF web service?

Create and configure a console app project for hosting a WCF service. Add code to host the WCF service. Update the configuration file. Start the WCF service and verify it's running.


1 Answers

You must configure your service to use HTTPS:

<bindings>
  <basicHttpBinding>
    <binding name="https">
      <security mode="Transport" />
    </binding>
  </basicHttpBinding>
</bindings>
<behaviors>
  <serviceBehaviors>
    <behavior name="metadata">
      <serviceMetadata httpsGetEnabled="true" />  
    </behavior>
  </serviceBehaviors>
</behaviors>
<services>
  <service name="..." behaviorConfiguration="metadata">
    <endpoint address="..." contract="..." binding="basicHttpBinding"
              bindingConfiguration="https" />
  </service>
</services>

This will allow calling your service only over HTTPS because there is no unsecured endpoint exposed. WSDL will also be accessible only over HTTPS because HTTP GET is not enabled.

like image 80
Ladislav Mrnka Avatar answered Oct 17 '22 00:10

Ladislav Mrnka