Showing posts with label unsuitable for SOAP services in silverlight. Show all posts
Showing posts with label unsuitable for SOAP services in silverlight. Show all posts

Friday, November 25, 2011

How to solve Siverlight application's 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?

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

 When you call WCF Service using Silverlight you might receive the above error message.

 Here i am showing you how to solve this problem , which i have got so many times thanks to Chanmingman's blog from where i able to solve this.

The Steps to follow

1. Create an xml file using notepad and save as clientaccesspolicy.xml with the following content.

<?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. Create an xml file using notepad and save as crossdomain.xml with the following content.

<?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="SOAPAction,Content-Type"/>
</cross-domain-policy>

3. Copy these 2 files into web site root folder for example, c:\inetpub\wwwroot. for your IIS 

Cheers :)