How to Configuring WCF services to work with both HTTP and HTTPS - multiple bindings not working

557 views Asked by At

Iam fairly new to Silver-light and WCF, so please bear with me.

I have silver-light application that calls .svc service. The service is being called successfully over https but i would also like to make it work with calls over plain http.

What modifications do i need to make to my web.config and ServiceReferences.ClientConfig files below.

My complete system.serviceModel section in my Web.config file is this.

 <system.serviceModel>     
    <bindings>
        <customBinding>
            <binding name="MyApp.Web.GetData.customBinding" receiveTimeout="00:30:00" sendTimeout="00:30:00" >
                <binaryMessageEncoding/>
                <httpsTransport/>
            </binding>
        </customBinding>
    </bindings>
    <services>
        <service name="MyApp.Web.GetData">
            <endpoint address="" binding="customBinding" bindingConfiguration="MyApp.Web.GetData.customBinding" contract="MyApp.Web.GetData" />
            <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
        </service>
    </services>      
    <behaviors>
        <serviceBehaviors>
            <behavior name="MyApp.Web.GetData">
                <serviceMetadata httpsGetEnabled="true" httpGetEnabled="true"/>
                <serviceDebug includeExceptionDetailInFaults="true"/>
                <dataContractSerializer maxItemsInObjectGraph="2147483646"/>
            </behavior>
            <behavior name="">
                <serviceMetadata httpsGetEnabled="true" httpGetEnabled="true" />
                <serviceDebug includeExceptionDetailInFaults="false" />
            </behavior>
        </serviceBehaviors>
    </behaviors>       
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>

And my complete ServiceReferences.ClientConfig file is below

<configuration>
<system.serviceModel>
    <bindings>
        <customBinding>
            <binding name="CustomBinding_GetData">
                <binaryMessageEncoding />
                <httpsTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
           </binding>
        </customBinding>
    </bindings>
    <client>
        <endpoint address="//localhost/MyApp.Web/Webservice/GetData.svc"
            binding="customBinding" bindingConfiguration="CustomBinding_GetData"
            contract="GetData.GetData" name="CustomBinding_GetData" />
    </client>
</system.serviceModel>

1

There are 1 answers

0
Yaron Naveh On

Try to add another endpoint and another binding with no ssl:

        </customBinding>
    </bindings>
    <client>
        <endpoint address="//localhost/MyApp.Web/Webservice/GetData.svc"
            binding="customBinding" bindingConfiguration="CustomBinding_GetData-ssl"
            contract="GetData.GetData" name="CustomBinding_GetData-ssl" />
        <endpoint address="//localhost/MyApp.Web/Webservice/GetData.svc"
            binding="customBinding" bindingConfiguration="CustomBinding_GetData"
            contract="GetData.GetData" name="CustomBinding_GetData" />
    </client>
</system.serviceModel>