【发布时间】:2011-06-22 16:57:45
【问题描述】:
我有一个 Silverlight 应用程序,它使用 WCF 与服务器进行通信。 Silverlight 和 WCF 都在本地计算机 (localhost) 上运行。当 Silverlight 调用该服务时,它会因通信异常而失败。 我知道这是因为我没有 clientaccesspolicy 文件,但由于 WCF 端点在http://localhost:port 上运行,我定义了一个接口 IPolicyRetriver,并向服务添加了一个实现,该实现在流中返回 clientaccesspolicy。
我的问题是,我必须进行哪些配置才能使其正常运行?我知道我必须在我的 ServiceReference.ClientConfig 文件中更改或添加一些内容,但我不明白是什么。我在下面包含了我的 ServiceReference.ClientConfig。请让我知道要更改或添加什么,以及在 Silverlight 中的何处添加此代码。 请不要在此处粘贴任何链接以帮助我,因为我在过去两天打开了所有可能的链接 - 但仍然不明白。
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IMapService" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="../MapService.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IMapService" contract="MapService.IMapService"
name="BasicHttpBinding_IMapService" />
</client>
</system.serviceModel>
请帮帮我!
【问题讨论】:
标签: silverlight wcf localhost service-reference