Silverlight 应用程序的 WCF
我创建了一个使用 WCF 服务的 Silverlight 2 应用程序。 该服务位于本地文件夹(不是 IIS)中,并且可以在 Winforms 测试中正常工作。 当我尝试调用该服务时,它返回错误:“跨域没有策略”。
我尝试将 clientaccesspolicy.xml 和 crossdomain.xml 添加到: wcf 项目文件夹 iis wwwroot 本地驱动器根目录 E:\
但没有任何影响 我应该把它们放在哪里?
I have created a Silverlight 2 appliction, that uses a WCF service.
The service is located in a local folder (not IIS) and works fine with a Winforms test.
when I try to call the service, it returns with an error: " no pocily for cross domain".
I've tryed to add clientaccesspolicy.xml and crossdomain.xml to:
the wcf project folder
the iis wwwroot
the local drive root E:\
but nothing takes any affect
where should i put them?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
正如您所说,您没有在 IIS 下运行该服务,我将做出一些假设
silverlight 应用程序和 wcf 服务托管在单独的 url 中,应用程序位于 file://example.html 或 http://localhost 如果您已将其发布到 http://localhost:1234 上的 IIS 和 wcf 服务。 这会引发跨域访问问题,因为端口号不同,或者您从 file:// URI 加载 silverlight 应用程序并且您自行托管 WCF 服务。 如果您自行托管 WCF 服务,则无法解决此问题,因为它们需要 clientaccesspolicy.xml 文件或 crossdomain.xml 文件,允许从 silverlight URL 访问服务,但是无法从根目录提供 XML自托管 WCF 服务器。
As you say you don't have the service running under IIS I am going to make some assumptions
The silverlight app and the wcf service are hosted in separate urls, the app on file://example.html or http://localhost if you've published it to IIS and the wcf service on http://localhost:1234. This raises cross domain access problems because the port numbers are different, or you are loading the silverlight app from a file:// URI and you're self hosting the WCF service. If you are self hosting the WCF service you cannot solve this because they require either a clientaccesspolicy.xml file or a crossdomain.xml file allowing access to the services from your silverlight URL, however there is no way to serve an XML from the root of the self hosting WCF server.
如果您要从 http://... 上下文转到 file://... 上下文,实际上这不是跨域问题。 相反,这是一个跨上下文问题,出于安全原因,Silverlight 2 中不允许这样做(http:// 和 https:// 也会发生这种情况)。 我不确定 Silverlight 3 中会是什么状态。
If you're going from an http://... context to a file://... context, it's not a cross-domain issue, actually. Instead, it's a cross-context issue, which is not allowed in Silverlight 2 (this also happens with http:// and https://) for security reasons. I'm not sure what the state of this will be in Silverlight 3.
也许您之后没有重新启动 IIS?
编辑:这是一个完整的教程,请确保您没有执行每一步以使其正常工作:Silverlight 2.0 和 WCF。
Perhaps you didn't restart IIS after that?
Edit : Here's a thorough tutorial, make sure you've don't every step to make it work : Silverlight 2.0 and WCF.
嗯...使用 fiddler 检查 clientaccesspolicy.xml 请求是否已发送。
另一方面,一个虚拟的客户端访问策略来检查连接是否正常工作:
但是,您应该尝试在同一个域上工作(如果您需要呼叫的安全性,那就更好了)。
Mm... check using fiddler if the clientaccesspolicy.xml request is sent.
On the other hand, a dummy clientaccesspolicy to check if the connection is working:
But, you should try to work on the same domain (better if you need security on your calls).