Introduction :
This Blog show the use of clientaccesspolicy.xml file and crossdomain.xml file in Silverlight-Wcf.
Explanation :
In order for Silverlight to call a remote resource on a different domain from where the XAP file was served such as a Web Service,the domain where the service must grant access to the Silverlight application. The way this is done is using an XML file with the name "clientaccesspolicy.xml" or "crossdomain.xml".
when our Silverlight application communicates with the server that served the application, the communication here is allowed because this is on the same domain from where your app was served.
But when your Silverlight application attempts to communicate with a 3rd party
remote server, a policy must exist (which is defined in either the "clientaccesspolicy.xml" or "crossdomain.xml" file) that allows this communication.
1.clientaccesspolicy.xml file
The clientaccesspolicy.xml file is located where the service is being hosted.
But Silverlight also supports this file. "clientaccesspolicy.xml" is specific to Silverlight
If we want to grant multiple domains access, an admin simply can modify the clientaccesspolicy.xml file.
<?xml version="1.0" encoding="utf-8" ?>
- <access-policy>
- <cross-domain-access>
- <policy>
- <allow-from http-request-headers="SOAPAction">
<domain uri="*" />
</allow-from>
- <grant-to>
<resource path="/" include-subpaths="true" />
</grant-to>
</policy>
</cross-domain-access>
</access-policy>
2.crossdomain.xml file
crossdomain.xml" was created originally for use with Flash applications.
<?xml version="1.0" ?>
<!DOCTYPE cross-domain-policy (View Source for full doctype...)>
- <cross-domain-policy>
<allow-http-request-headers-from domain="*" headers="SOAPAction,Content-Type" secure="true" />
</cross-domain-policy>
Note :
For communication between specific Silverlight application and server,these both files do not need to present.
If we want to access bot silverlight application and Flash Application that time we can have only crossdomain.xml file.
Thanks.