Debugging and Making a Service Available Across Domain Boundaries in Silverlight Application

If you encounter this kind of an error message:

“An error occurred while trying to make a request to URI ‘http://localhost...’. 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“

You need to check for Cross-Domain Issues as follows :

If the domain of the application URL is different from the domain of the service URL, you have a cross-domain situation. Access of a service across domains requires that the service have a cross-domain policy file. There are two kinds of cross-domain policy files: Clientaccesspolicy.xml and Crossdomain.xml.

1. ClientAccessPolicy.xml file: This file is defined by Silverlight. It can be used only granting access to Silverlight applications, however this file provides more granular control over allowed domains. . If you want to use this file you should create a clientaccesspolicy.xml file that allows access to the service and save it to the root of the domain where the service is hosted. The following configuration allows access from any other domain to all resources on the current domain.


  
    
      
        
      
      
        
      
    
  



2. Crossdomain.xml File: This file is defined by Adobe Flash. It can be used if you want your service to grant access to both Adobe and Silverlight application. If you want to use this file you should create a crossdomain.xml file that contains the following configuration and save it to the root of the domain where the service is hosted. The file must be configured to allow access to the service from any other domain, or it is not recognized by Silverlight 4.




  

No comments:

Post a Comment