如何为支持 AJAX 的 WCF 服务同时启用 HTTP 和 HTTPS?
这是我的配置设置,目前仅允许 HTTP:
<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,但由于不能混合协议,我将满足于允许使用当前页面使用的任何协议来调用服务。
Here is my config settings, which currently only allows HTTP:
<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" />
This service could potentially be called on any page on my website. Some pages are HTTPS, so I would like to set it up so that the service can be called (AJAX) using either protocol. Ideally, I would like all my AJAX service calls to be HTTPS, but since you can't mix protocols, I will settle for allowing the service to be called using what ever protocol the current page is using.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在黑暗中拍摄:
您需要添加另一个绑定(通常在您显示的代码上方声明),然后声明另一个端点。
Shot in the dark:
You'll need to add another Binding (declared above the code you show (normally)), and then declare another endpoint.