WCF avec custombinding sur http et https

j'ai un service WCF avec custombinding et il fonctionne très bien sur http ou https. Mais je n'ai aucune idée de comment le rendre disponible sur http et https?

est-il également possible de faire cela?

voici ma configuration dans 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>

Merci

9
demandé sur aunghn 2011-06-01 07:22:49

1 réponses

vous aurez besoin de deux paramètres, L'un pour HTTP et l'autre pour HTTPS. Il devrait fonctionner très bien.

<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> 
10
répondu carlosfigueira 2011-06-01 05:18:23