I need help configuring WCF to support multiple environments. One environment allows anonymous authentication through standard HTTP, while the other uses Windows authentication through SSL.
I can configure WCF to support any of these environments, but not in the same web.config file.
Here, which allows anonymously on 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>
And here is what works for Windows authentication over 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>
When I add the endpoint from the SSL configuration to the non-SSL configuration, the anonymous service is interrupted.
Here is a configuration file that does not work, but tries to bring both parameters together:
<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>
Is there a way to combine endpoints into one web.config to support two environments?
source share