WCF Silverlight跨域问题
我有几个 WCF 服务。 当我在服务器上检查它们时(例如:ServiceTest.svc?wsdl),我看到一个包含有关 wcf 服务信息的 xml 文件。所以服务运作良好。
我在不同的服务器上有一个 Silverlight 应用程序。 我收到“著名的”跨域错误。 当我将 clientaccesspolicy.xml 放入包含 WCF 服务的目录中时,问题仍然存在。
共享主机的安全性是否可能不够高/低?
谢谢,
菲利普
I have several WCF services.
When I check them on the server (example: ServiceTest.svc?wsdl), than I see an xml file with info about the wcf service. So the services works fine.
I have a Silverlight application on a different server.
I get the 'famous' crossdomain error.
When I place a clientaccesspolicy.xml in the directory with the WCF services, the problem remains.
Is it possible that with shared hosting, the security isn't high/low enough?
thanks,
Filip
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
XML 文件必须放置在域的根目录中。通常您必须将它们放入 inetpub/wwwroot 文件夹中,而不是放入包含 WCF 服务的文件夹中。
根据您的提供商实现共享托管的方式,恐怕您必须要求他们支持跨域访问并将 XML 文件放入根目录中。
我不确定,但我认为也可以注册您自己的域,该域指向您想要用作 root 的文件夹,并将 XML 文件放在那里。当然,客户端必须将服务器 URL 与您注册的域一起使用。
The XML file must be placed in the root of the domain. Usually you have to put them into the inetpub/wwwroot folder, instead of into the folder with the WCF services.
Depending on how your provider implemented the shared hosting, I'm afraid you'll have to ask them to support cross domain access and put the XML files into the root.
I am not sure but I think it also could work to register your own domain that points to the folder you want to use as root, and put the XML files there. The clients must then use the server URLs with your registered domain of course.
解决此类问题的最佳工具之一是 Fiddler(或其他一些 Web 调试代理)。查看网络调用,您可以看到浏览器在其中查找 clientaccesspolicy.xml 文件的地址,然后确保将该文件放置在该位置。如果您没有看到此调用,或者您看到了它并且文件已存在,则可以继续处理其他问题(Web 服务或调用代码中的错误)。
One of the best tools for issues like this is Fiddler(or some other web debugging proxy). Looking at the network calls, you can see the address where the browser is looking for the clientaccesspolicy.xml file and then make sure you drop the file at that location. If you're not seeing this call or you're seeing it and the file is already there, you can move on to other issues (a bug in the webservice or the calling code).