我需要一些帮助来配置WCF以支持多个环境。一种环境允许通过标准HTTP进行匿名身份验证,而另一种环境则通过SSL使用Windows身份验证。
我可以配置WCF来支持这两种环境中的任何一种,但不能同时支持这两种环境web.config文件文件。
<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>
下面是通过SSL进行Windows身份验证的方法:
<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>
<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>
有什么方法可以把端点合并成一个吗web.config文件支持这两种环境?