How to use SSL with a WCF web service?

Posted by Martin on Stack Overflow See other posts from Stack Overflow or by Martin
Published on 2010-12-21T15:47:09Z Indexed on 2010/12/21 23:54 UTC
Read the original article Hit count: 171

Filed under:
|
|

I have a web service in asp.net running and everything works fine. Now I need to access some methods in that web-service using SSL. It works perfect when I contact the web-service using http:// but with https:// I get "There was no endpoint listening at https://...".

Can you please help me on how to set up my web.config to support both http and https access to my web service. I have tried to follow guidelines but I can't get it working.

Some code:

My TestService.svc:

[ServiceContract(Namespace = "")]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class TestService
{
    [OperationContract]
    [WebGet(ResponseFormat = WebMessageFormat.Json)]
    public bool validUser(string email) {
        return true;
    }
}

My Web.config:

<system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
        <behaviors>
            <endpointBehaviors>
                <behavior name="ServiceAspNetAjaxBehavior">
                    <enableWebScript />
                </behavior>
            </endpointBehaviors>
            <serviceBehaviors>
                <behavior name="ServiceBehavior">
                    <serviceDebug includeExceptionDetailInFaults="true" />
                </behavior>
                <behavior name="">
                    <serviceMetadata httpGetEnabled="true" />
                    <serviceDebug includeExceptionDetailInFaults="false" />
                </behavior>
            </serviceBehaviors>
        </behaviors>
        <services>
            <service behaviorConfiguration="ServiceBehavior" name="TestService">
                <endpoint address="" behaviorConfiguration="ServiceAspNetAjaxBehavior"
                     binding="webHttpBinding" bindingConfiguration="ServiceBinding"
                     contract="TestService" />
            </service>
        </services>
        <bindings>
            <webHttpBinding>
                <binding name="ServiceBinding" maxBufferPoolSize="1000000" maxReceivedMessageSize="1000000">
                    <readerQuotas maxDepth="1000000" maxStringContentLength="1000000" maxArrayLength="1000000" maxBytesPerRead="1000000" maxNameTableCharCount="1000000"/>
                </binding>
            </webHttpBinding>
        </bindings>
</system.serviceModel>

© Stack Overflow or respective owner

Related posts about wcf

Related posts about web-services