2012-01-19 104 views
1

这里是我的配置设置,目前只允许HTTP:如何为启用AJAX的WCF服务启用HTTP和HTTPS?

<system.serviceModel> 
<services> 
    <service name="MyAjaxSvc"> 
    <endpoint address="" behaviorConfiguration="MyAjaxSvcEndpointBehavior" 
       binding="webHttpBinding" 
       contract="MyAjaxSvc" /> 
    </service> 
</services> 
<behaviors> 
    <endpointBehaviors> 
    <behavior name="MyAjaxSvcEndpointBehavior"> 
     <enableWebScript /> 
    </behavior> 
    </endpointBehaviors> 
    <serviceBehaviors> 
    <behavior name=""> 
     <serviceMetadata httpGetEnabled="true" /> 
     <serviceDebug includeExceptionDetailInFaults="false" /> 
    </behavior> 
    </serviceBehaviors> 
</behaviors> 
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /> 

该服务可能在我的网站的任何页面上调用。有些页面是HTTPS,所以我想设置它以便可以使用任一协议调用服务(AJAX)。理想情况下,我希望所有的AJAX服务调用都是HTTPS,但由于您无法混合使用协议,因此我决定允许使用当前页面使用的任何协议来调用服务。

回答

0

瞎猜:

你需要添加另一个绑定(你的代码显示(正常)上述声明),然后声明另一个端点。

+0

非常好。我将第二个绑定的安全模式设置为'transport',并且一切正常。谢谢! – tjc59