【发布时间】:2011-05-19 18:36:35
【问题描述】:
我有一个 Silverlight 4 应用程序,它在同一台服务器(自托管)上使用 WCF 服务。一切正常,但现在我想将我的 WCF 服务转换为使用 SSL。我正在使用 CustomBindings 并且找不到完成此操作的组合。我在客户端使用相对 URL,希望这不会引起问题。以下是我的 Web.config 文件的重要部分:
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<dataContractSerializer maxItemsInObjectGraph="6553600"/>
<serviceTimeouts transactionTimeout="00:10:00"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<customBinding>
<binding name="MyApp.Web.Services.ProjectService.customBinding0"
receiveTimeout="00:10:00" sendTimeout="00:10:00">
<binaryMessageEncoding />
<httpsTransport maxReceivedMessageSize="2147483647" />
</binding>
</customBinding>
</bindings>
<services>
<service name="MyApp.Web.Services.ProjectService">
<endpoint address="" binding="customBinding" bindingConfiguration="MyApp.Web.Services.ProjectService.customBinding0"
contract="MyApp.Web.Services.ProjectService" />
</service>
我的 ClientConfig 如下所示:
<configuration>
<system.serviceModel>
<bindings>
<customBinding>
<binding name="CustomBinding_ProjectService">
<binaryMessageEncoding />
<httpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="../Services/ProjectService.svc" binding="customBinding"
bindingConfiguration="CustomBinding_ProjectService" contract="SearchProxy.ProjectService"
name="CustomBinding_ProjectService" />
</client>
</system.serviceModel>
</configuration>
我只是不明白绑定在服务器和客户端中是如何工作的。我希望有人能指出我正确的方向。
【问题讨论】:
-
你说服务是“自托管的”,但是你发布了一个web.config;服务是否托管在 IIS 中,或者您是否有一个带有您实际打开的 ServiceHost 实例的程序?
-
我的意思是我的 WCF 服务托管在我的 Silverlight 项目的 Web 项目中。我只想将它们转换为 SSL,但我还需要能够在我的本地机器上调试/开发。我会看看你的答案,看看我能找到什么。谢谢!
-
当我在我的服务中设置 httpsTransport(并在行为中设置 httpsGetEnabled=true),然后尝试从我的 silverlight 应用程序更新它时,我收到以下错误:“下载时出错地址中的元数据。请验证您输入的地址是否有效”。有什么想法吗?
-
您更改了服务地址(从 http 到 https),因此您需要“配置服务引用”来更新客户端中的地址。
-
我提到的错误是我尝试添加新服务引用时遇到的错误。在我的 web.config 中进行上述更改后,我将无法再通过 Visual Studio 访问该服务。
标签: silverlight wcf ssl