Search code examples
wcfhttphttpsbasichttpbinding

BasicHttpBinding Supporting HTTP & HTTPS Without Configuration Changes


I've written a WCF client application which uses a BasicHTTPBinding to communicate with a remote PHP-powered web service. Multiple instances of the web service are run on different servers. Some of these instances are exposed via HTTP; others, via HTTPS. The user can configure my application to access any desired service instance by providing the appropriate HTTP or HTTPS URL.

Is there a way for me to set one endpoint configuration that works for both HTTP and HTTPS URLS?

Thank you,
Ben


Solution

  • Since each WCF endpoint is associated with one and only one WCF binding, there's no way for a single endpoint to respond to both HTTP & HTTPS configurations.

    Assuming your code is setting the endpoint URL somehow at runtime, you can take advantage of this to inspect the URL and dynamically configure the binding also as shown in this blog post.