0

所以我最近一直在部署一个 Silverlight 网站,我刚刚注意到一些非常可怕的错误。

我的 Silverlight 应用程序有 5 个绑定到托管在同一网站上的 Web 应用程序上的 wcf 服务,前面只有一个文件夹。假设我的网站是www.test.com。下面是来自 silverlight 应用的 ServiceReferences.ClientConfig 的绑定:

<client>
    <endpoint address="http://www.test.com/MyWebService/Service1.svc"
        binding="customBinding" bindingConfiguration="CustomBinding_IService1"
        contract="Service1.IService1" name="CustomBinding_IService1" />
    <endpoint address="http://www.test.com/MyWebService/Service2.svc"
        binding="customBinding" bindingConfiguration="CustomBinding_IService2"
        contract="Service2.IService2" name="CustomBinding_IService2" />
    <endpoint address="http://www.test.com/MyWebService/Service3.svc"
        binding="customBinding" bindingConfiguration="CustomBinding_IService3"
        contract="Service3.IService3" name="CustomBinding_IService3" />
    <endpoint address="http://www.test.com/MyWebService/Service4.svc"
        binding="customBinding" bindingConfiguration="CustomBinding_IService4"
        contract="Service4.IService4" name="CustomBinding_IService4" />
    <endpoint address="http://www.test.com/MyWebService/Service5.svc"
        binding="customBinding" bindingConfiguration="CustomBinding_IService5"
        contract="Service5.IService5" name="CustomBinding_IService5" />
</client>

所以我的问题是,当我加载 Silverlight 应用程序时,在托管在我的 IIS 网站根目录的默认 aspx 页面上,连接仅在我在 URL 地址中键入test.com时才起作用,而不是在我键入www.test时.com _ 它没有失败,但是应该通过服务提取的数据只是没有显示,而且我无法连接我的凭据。(因为我的一项服务用于身份验证)

我尝试通过删除www更改我的应用程序的 ServiceReferences.ClientConfig 的值,但情况并没有改变一点。如果没有网址中的 www,它仍然可以很好地连接,并且在打开 www 时连接不好。

4

1 回答 1

0

好吧,多亏了这篇可爱的帖子,我才能克服这个问题。我将在这里解释我必须做什么,以防万一链接失效。

我所要做的就是在我的 Silverlight 代码中更改每个服务客户端的每个实例:

Service.IService proxy = new Service.ServiceClient();

对此:

Uri servUri = new Uri("../MyWebService/Service.svc", UriKind.Relative);
EndpointAddress servAddr = new EndpointAddress(servUri);
Service.IService proxy = new Service.ServiceClient("CustomBinding_IService", servAddr);

如博客文章中所述,“..”是必需的,因为 Silverlight 应用程序(通常)位于ClientBin文件夹中。

这对我有用!

于 2013-02-17T16:12:36.230 回答