在本地运行的silverlight无法访问Web服务 [英] silverlight running on local cannot access web service
问题描述
我编写了一个带有sivlerlight对象的简单html页面。 silverlight应用程序调用Web服务来获取字符串,比如说"hello world"。然后我将我的sivlerlight页面放在我的本地IIS上。如果我从网络地址访问该页面,例如 http:// localhost 或 http:// mybox ,我的页面有效。但是,如果我直接双击该页面,我收到以下错误:
在尝试向URI"http://mybox/webservice/service.asmx"发出请求时发生错误。这可能是由于尝试在没有适当的跨域策略的情况下以跨域方式访问服务,或者是不适合SOAP服务的策略。您可能需要联系服务的所有者以发布跨域策略文件,并确保它允许发送与SOAP相关的HTTP标头。有关更多详细信息,请参阅内部异常。
我知道此错误与x-domain访问有关,我已将clientaccesspolicy.xml文件添加到IIS的根目录,其中包含以下内容:
$
Hi,
I coded a simple html page with a sivlerlight object in it. The silverlight application calls a web service to get a string, say 'hello world'. I then put my sivlerlight page on my local IIS. If I access that page from a network address, e.g. http://localhost, or http://mybox, my page works. But if I directly double click that page, I got the following error:
An error occurred while trying to make a request to URI 'http://mybox/webservice/service.asmx'. This could be due to attempting to access a service in a cross-domain way without a proper cross-domain policy in place, or a policy that is unsuitable for SOAP services. You may need to contact the owner of the service to publish a cross-domain policy file and to ensure it allows SOAP-related HTTP headers to be sent. Please see the inner exception for more details.
I know that this error is related to x-domain access, and I have added the clientaccesspolicy.xml file to the root of my IIS, with the following content:
<?xml version="1.0" encoding="utf-8" ?>
<access-policy>
<cross-domain-access>
<policy>
<allow-from http-request-headers="*">
<domain uri="*"/>
</allow-from>
<grant-to>
<resource include-subpaths="true" path="/"/>
</grant-to>
</policy>
</cross-domain-access>
</access-policy>
我用Fiddler来监控http请求,我看到该文件是用代码200检索的。
请帮助,谢谢!
享受:)
I used Fiddler to monitor the http request, and I see that file is retrieved with code 200.
Please help, thanks!
Enjoy :)
推荐答案
嗨DavidShen,确保在IIS配置中,在您的机器名称的属性和"主目录"中。选项卡"读取"选项被标记。也许应用程序无法读取您的策略文件'因为在IIS中未选中此选项。确保在您的服务属性下检查相同的选项。
Hi DavidShen,
ensure that in the IIS configuration, in the properties of the name of your machine and in the "Home Directory" tab the option "Read" is flagged. Maybe the application can´t read your policy file ´cause in the IIS this option is not checked. Ensure aswell that the same option is checked under the properties of your service.
这篇关于在本地运行的silverlight无法访问Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!