【发布时间】:2011-06-13 01:11:14
【问题描述】:
我们的 Silverlight 应用程序可以在 http 和 https(SSL,使用 Transport 安全性)模式下运行。在我们的ServiceReferences.ClientConfig 文件中,我们简单地以这种方式配置了我们的服务端点:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="DefaultEndpoint"
maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<security mode="None" />
<!-- Enable for SSL: mode="Transport" -->
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="/services/DefaultService.svc"
binding="basicHttpBinding"
bindingConfiguration="DefaultEndpoint"
contract="OurNamespace.IOurContractAsync"
name="DefaultEndpoint" />
</client>
</system.serviceModel>
</configuration>
可以在两种模式下访问配置的端点。它只取决于加载 XAP 文件的上下文:来自http://example.com/slpage.html 或https://example.com/slpage.html。不幸的是,我们必须在“无”和“传输”之间手动切换安全模式设置。其他一切都已经按需要工作了。当安全模式为“无”并且我们通过 https 访问时,我们会得到一个异常“.. https is provided but http is expected...”,反之亦然。有没有机会让 Silverlight 自动决定应该使用哪种安全模式?解决这个问题最简单的方法是什么?
提前致谢
托马斯
【问题讨论】:
标签: silverlight wcf ssl silverlight-4.0