【转贴】Silverlight 解决方案 access a service in a cross-domain way

在开发手机项目的时候,从Windows Phone7应用程序调用webservice的时候发生了异常,与下面描述的类似。

 http://hi.baidu.com/laozhenghit/blog/item/b912a60d72a325e6aa645747.html

Excepition like:

"An error occurred while trying to make a request to URI 'http://www.mywebsite.com/webser/emailsender.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."

solution:

copy following as clientaccesspolicy.xml to root of web server

<?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 path="/" include-subpaths="true"/>
      </grant-to>
    </policy>
</cross-domain-access>
</access-policy>

posted on 2011-05-03 10:38  jojozhuang  阅读(432)  评论(0)    收藏  举报