Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF with custombinding on both http and https

I have a WCF service with custombinding and it is working fine on either http or https. But I have totally no idea about how can I make it available on both http and https?

Also is it possible to do that?

Here's my configuration in web.config.

<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
<behaviors>
    <serviceBehaviors>
        <behavior name="">
            <serviceMetadata httpsGetEnabled="true" />                    
            <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>         
    </serviceBehaviors>
</behaviors>
<bindings>
    <customBinding>                     
        <binding name="customBinding0">
          <binaryMessageEncoding />
          <httpsTransport />
        </binding>
    </customBinding>
</bindings>
<services>
    <service name="MyWCFService">                           
        <endpoint address="" binding="customBinding" bindingConfiguration="customBinding0"
            contract="MyWCFService" />
        <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
    </service>      
</services>

Thanks

like image 479
aunghn Avatar asked Jun 01 '11 03:06

aunghn


1 Answers

You'll need to have two endpoints, one for HTTP and another for HTTPS. It should work just fine.

<bindings>
    <customBinding>
        <binding name="customBindingHTTP">
            <binaryMessageEncoding />
            <httpTransport />
        </binding>
        <binding name="customBindingHTTPS">
            <binaryMessageEncoding />
            <httpsTransport />
        </binding>
    </customBinding>
</bindings>
<services>
    <service name="MyWCFService">
        <endpoint address=""
                  binding="customBinding"
                  bindingConfiguration="customBindingHTTP"
                  contract="MyWCFService" />
        <endpoint address=""
                  binding="customBinding"
                  bindingConfiguration="customBindingHTTPS"
                  contract="MyWCFService" />
        <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
    </service> 
</services> 
like image 144
carlosfigueira Avatar answered Oct 25 '22 11:10

carlosfigueira