Monday, 27 October 2008

Silverlight and Cross domain services

Silverlight 2 allows you to invoke a web service on a different domain to where your XAP came from. In order to do this however, the owner of the service needs to enable it to allow cross domain calls.

This entails creating an xml file in the root of the service web server called clientaccesspolicy.xml. A skeleton of this file, allowing any caller from any domain, is shown below;

<?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>

No comments:

Post a Comment