In our project we have a java web service that runs over http and https. We want to use http internally and https for the external version of our web app.
So we've created the proxy class in our application and we have setup the binding for http in the web/app.config and all works fine.
What changes would we need to make to the code and the configuration to support https for the same service in our external application? If possible please supply code snippets to explain!
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.
Web services support only one protocol- HTTP and HTTPS during communication, but WCF supports more protocols like- HTTP, TCP, and MSMQ that can be extended for a comprehensive solution, reliable session, and transactions. It signifies WCF is more adaptable to work together for a variety of software.
I found an answer digging around MSDN.
In my case, I was using a custom binding:
<customBinding>
<binding name="jsonpBinding">
<jsonpMessageEncoding/>
<httpTransport manualAddressing="true"/>
</binding>
</customBinding>
That was referenced in the service
<services>
<service name="{YourInfoHere}">
<endpoint address="" binding="customBinding" bindingConfiguration="jsonpBinding" behaviorConfiguration="{YourInfoHere}" contract="{YourInfoHere}"/>
</service>
</services>
Adding a second binding that used httpsTransport and then a second service that used that binding did the trick. Final output:
<services>
<service name="{YourInfoHere}">
<endpoint address="" binding="customBinding" bindingConfiguration="jsonpBinding" behaviorConfiguration="{YourInfoHere}" contract="{YourInfoHere}"/>
<endpoint address="" binding="customBinding" bindingConfiguration="jsonpBindingHttps" behaviorConfiguration="{YourInfoHere}" contract="{YourInfoHere}"/>
</service>
</services>
<bindings>
<customBinding>
<binding name="jsonpBinding">
<jsonpMessageEncoding/>
<httpTransport manualAddressing="true"/>
</binding>
<binding name="jsonpBindingHttps">
<jsonpMessageEncoding/>
<httpsTransport manualAddressing="true" />
</binding>
</customBinding>
</bindings>
May not be ideal, but it works. These were the only changes I made to make SSL work. Since it is all in the binding & transport, the code remains the same.
Relevant MSDN links:
I am assuming that you are using basichttpbinding. Then you need to do two things:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With