2010-08-26 7 views
4

J'ai besoin d'aide pour configurer WCF pour prendre en charge plusieurs environnements. Un environnement permet l'authentification anonyme sur HTTP standard et l'autre utilise l'authentification Windows via SSL.Comment configurer WCF pour accepter SSL et non SSL

Je peux configurer WCF pour prendre en charge l'un des environnements, mais pas les deux dans le même fichier web.config.

est ici ce qui permet à l'anonymat sur http:

<behaviors> 
    <serviceBehaviors> 
     <behavior name="MexBehavior" > 
      <serviceMetadata httpGetEnabled="true" /> 
     </behavior> 
    </serviceBehaviors> 
    <endpointBehaviors> 
     <behavior name="DLAspNetAjaxBehavior"> 
      <enableWebScript/> 
     </behavior> 
     <behavior name="Service1AspNetAjaxBehavior"> 
      <webHttp/> 
     </behavior> 
    </endpointBehaviors> 
</behaviors> 
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/> 
<services> 
    <service name="DL" behaviorConfiguration="MexBehavior"> 
     <endpoint address="" behaviorConfiguration="DLAspNetAjaxBehavior" binding="webHttpBinding" contract="DLService"/> 
     <endpoint name="MEXEndpoint" contract="IMetadataExchange" binding="mexHttpBinding" address="mex" /> 
    </service> 
    <service name="Service1" behaviorConfiguration="MexBehavior"> 
     <endpoint address="" behaviorConfiguration="Service1AspNetAjaxBehavior" binding="webHttpBinding" contract="Service1"/> 
     <endpoint name="MEXEndpoint" contract="IMetadataExchange" binding="mexHttpBinding" address="mex" /> 
    </service>   
</services> 

Et voici ce qui fonctionne pour l'authentification Windows sur SSL:

<behaviors> 
    <serviceBehaviors> 
     <behavior name="MexBehavior" > 
      <serviceMetadata httpGetEnabled="true" /> 
     </behavior> 
    </serviceBehaviors> 
    <endpointBehaviors> 
     <behavior name="DLAspNetAjaxBehavior"> 
      <enableWebScript/> 
     </behavior> 
     <behavior name="Service1AspNetAjaxBehavior"> 
      <webHttp/> 
     </behavior> 
    </endpointBehaviors> 
</behaviors> 
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/> 
<services> 
    <service name="DL" behaviorConfiguration="MexBehavior"> 
     <endpoint address="" behaviorConfiguration="DynamicLoaderAspNetAjaxBehavior" binding="webHttpBinding" bindingConfiguration="webWinBinding" contract="DLService"/> 
     <endpoint name="MEXEndpoint" contract="IMetadataExchange" binding="mexHttpBinding" address="mex" /> 
    </service> 
    <service name="Service1" behaviorConfiguration="MexBehavior"> 
     <endpoint address="" behaviorConfiguration="ValidValuesServiceAspNetAjaxBehavior" binding="webHttpBinding" bindingConfiguration="webWinBinding" contract="Service1"/> 
     <endpoint name="MEXEndpoint" contract="IMetadataExchange" binding="mexHttpBinding" address="mex" /> 
    </service>   
</services>  
<bindings> 
    <webHttpBinding> 
     <binding name="webWinBinding"> 
      <security mode="Transport"> 
       <transport clientCredentialType="Windows" /> 
      </security> 
     </binding> 
    </webHttpBinding>   
</bindings> 

Lorsque j'ajoute le point final de la configuration SSL à la configuration non-SSL , le service anonyme casse.

Voici le fichier de configuration qui ne fonctionne pas, mais tente de mettre les deux paramètres ensemble:

<behaviors> 
    <serviceBehaviors> 
     <behavior name="MexBehavior" > 
      <serviceMetadata httpGetEnabled="true" /> 
     </behavior> 
    </serviceBehaviors> 
    <endpointBehaviors> 
     <behavior name="DLAspNetAjaxBehavior"> 
      <enableWebScript/> 
     </behavior> 
     <behavior name="Service1AspNetAjaxBehavior"> 
      <webHttp/> 
     </behavior> 
    </endpointBehaviors> 
</behaviors> 
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/> 
<services> 
    <service name="DynamicLoader" behaviorConfiguration="MexBehavior"> 
     <endpoint name="basic" address="" behaviorConfiguration="DLAspNetAjaxBehavior" binding="webHttpBinding" bindingConfiguration="webAnonymousBinding" contract="DLService"/> 
     <endpoint name="secure" address="" behaviorConfiguration="DLAspNetAjaxBehavior" binding="webHttpBinding" bindingConfiguration="webWinBinding" contract="DLService"/> 
     <endpoint name="MEXEndpoint" contract="IMetadataExchange" binding="mexHttpBinding" address="mex" /> 
    </service> 
    <service name="ValidValuesService" behaviorConfiguration="MexBehavior"> 
     <endpoint name="basic" address="" behaviorConfiguration="Service1AspNetAjaxBehavior" binding="webHttpBinding" bindingConfiguration="webAnonymousBinding" contract="Service1"/> 
     <endpoint name="secure" address="" behaviorConfiguration="Service1AspNetAjaxBehavior" binding="webHttpBinding" bindingConfiguration="webWinBinding" contract="Service1"/> 
     <endpoint name="MEXEndpoint" contract="IMetadataExchange" binding="mexHttpBinding" address="mex" /> 
    </service> 
</services> 
<bindings> 
    <webHttpBinding> 
     <binding name="webWinBinding"> 
      <security mode="Transport"> 
       <transport clientCredentialType="Windows" /> 
      </security> 
     </binding> 
     <binding name="webAnonymousBinding"> 
      <security mode="None"> 
      </security> 
     </binding> 
    </webHttpBinding> 
</bindings> 

Est-il possible que je peux combiner les points d'extrémité dans un web.config pour soutenir les deux environnements?

+0

Avez-vous pour soutenir les environnements en même temps, ou est un environnement un DEV (non-SSL) et l'autre est QA ou PROD (SSL)? –

+0

concurrent. Il existe une interface interne et externe pour la même application et l'une utilise SSL avec l'authentification Windows et l'autre est non SSL avec l'authentification par formulaires anonyme. –

Répondre

0

Est-ce que cette question/réponse SO précédente a été utile?

calling a web service using WCF over Http and Https

(Voir la première réponse.)

+0

Non, ça ne marche pas pour moi. Je vais modifier la question pour montrer le fichier de configuration combiné qui ne fonctionne pas. Merci! –