我正在尝试使用HTTPS创建的自托管WCF服务。我可以使用WCFClientTest工具和网络浏览器访问服务,但是我的silverlight应用程序无法工作。我收到以下错误:
This could be due to 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.我确实有clientaccesspolicy.xml,当我通过fiddler查看它时,我可以看到silverlight应用程序正在正常运行。xml文件包含以下内容:
<access-policy>
<cross-domain-access>
<policy>
<allow-from http-request-headers="*">
<domain uri="*"/>
</allow-from>
<grant-to>
<resource path="/" include-subpaths="true"/>
</grant-to>
</policy>
</cross-domain-access>
</access-policy>问题是,即使silverlight应用程序似乎正在请求和接收该文件,它仍然会抛出需要允许跨域访问的错误消息。有什么想法吗?
提前谢谢。
发布于 2012-09-12 23:33:28
注意您的应用程序正在尝试使用WCF服务的地址和端口。使用Fiddler查看它在哪里调用(我遇到过很多这样的问题,因为VS的错误是相同的……它找不到服务)。
不管怎样,这里你有一个正在工作的clientaccesspolicy.xml:
<?xml version="1.0" encoding="utf-8"?>
<access-policy>
<cross-domain-access>
<policy>
<allow-from http-request-headers="SOAPAction">
<domain uri="http://*"/>
<domain uri="https://*"/>
</allow-from>
<grant-to>
<resource path="/" include-subpaths="true"/>
</grant-to>
</policy>
</cross-domain-access>
</access-policy>发布于 2012-09-12 23:22:07
您需要一个单独的域节点用于https:
<domain uri="https://*" /> 有关跨域的更多信息,请访问:http://msdn.microsoft.com/en-us/library/dd470115(VS.95).aspx & http://blogs.msdn.com/b/carlosfigueira/archive/2008/03/07/enabling-cross-domain-calls-for-silverlight-apps-on-self-hosted-web-services.aspx
希望这个链接能帮上忙。
https://stackoverflow.com/questions/12391408
复制相似问题