Pick a Silverlight RIA scenario [D2D, B2E, B2B, B2C] or choose a Web Services style [SOAP/RPC, XML/REST]

Cross Domain : Trouble while accessing Web Services

When Silverlight attempts to access a Web Service, if the SOO is different from the Web Service host, you have to deal with a cross domain issue. This issue can occur in various scenarios as described in Silverlight scenarios for Rich Internet Applications

The issue can be treated as follow :

1.  I am encountering a ProtocolException

image

  • Reason

    Silverlight is attempting to access a Web Service which is across its own domain boundaries. For security reasons, a policy file must exist at the root of the Web Service host. It allows this cross-domain access : it’s either clientaccesspolicy.xml or crossdomain.xml files which were not found by Silverlight.

    image 

2.  Even if the clientaccesspolicy.xml is found, my Silverlight application access the service

  • Reason

    Indeed, the clientaccesspolicy.xml file is here but is not accepted by the Silverlight application : there is some missing information. 

    image

    There has been some modifications since Silverlight 2 beta 2 : Ensure that ‘http-request-headers’ attribute is correctly set in ‘allow-from’ element in the clientaccesspolicy.xml file. See below for a basic and working policy file :
<?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>

More information can be found at

http://msdn.microsoft.com/en-us/library/cc197955(VS.95).aspx

- Ronny Kwon

Published 31 July 08 01:56 by Steve SFARTZ
Filed under:

Comments

# A Cup of Silverlight, RIA & Interoperability said on August 5, 2008 8:16 AM:

The How-To series demo Silverlight accessing Web Services in various configuration. In this post, we

# A Cup of Silverlight, RIA & Interoperability said on August 6, 2008 3:49 AM:

The HowTo serie demoes Silverlight accessing Web Services in various configurations. In this post, we

# A Cup of Silverlight, RIA & Interoperability said on August 11, 2008 8:24 AM:

This tip concerns those who wants to use self hosting capabilities of services in WCF or Restlet in cross-domain

Anonymous comments are disabled

About Steve SFARTZ

I work for Microsoft France as a Technology Evangelist with expertise in Enterprise Architecture, Interoperability, SOA & Cloud Computing.
Contact me or read one of my other blogs : Think Big mais pas trop..., SOA & Interop @Microsoft France, Cloud Computing @ Microsoft France, Silverlight, RIA & Interoperability

Au sein de l'équipe Entreprise de Microsoft France, je me concentre sur les problématiques Cloud Computing, SOA et Interopérabilité.
Contactez-moi ou bien consultez l'un de mes blogs : Think Big mais pas trop..., SOA & Interop @Microsoft France, Cloud Computing @ Microsoft France, Silverlight, RIA & Interoperability

Search

This Blog

Syndication

Page view tracker