Step 3:- Copy the CrossDomain.xml and ClientAccessPolicy.XML file
This WCF service is going to be called from an outside domain, so we need to enable the cross domain policy in the WCF service by creating ‘CrossDomain.xml’ and ‘ClientAccessPolicy.xml’. Below are both the code snippets. The first code snippet is for cross domain and the second for client access policy.
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-http-request-headers-from domain="*" headers="*"/>
</cross-domain-policy>
<?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>
Step 4:- Change the WCF bindings to ‘basicHttpBinding’
Silverlight consumes and generates proxy for only ‘basicHttpBinding’ , so we need to change the endpoint bindings accordingly.
<endpoint address="" binding="basicHttpBinding" contract="WCFDatabaseService.IServiceCustomer">
Step 5:- Add service reference
We need to consume the service reference in silverlight application using ‘Add service reference’ menu. So right click the silverlight project and select add service reference.
Asked In: Many Interviews |
Alert Moderator