2012-01-19 39 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