This could be due to attempting to access a service in a cross-domain way without a proper cross-dom

Posted by SheoNarayan under Error and Solution on 8/30/2011 | Points: 10 | Views : 13992 | Status : [Administrator] | Replies : 6

I was getting following error when consuming web service in Silverlight application. This was happening because my Web Service is hosted on other domain (in local, it exists in a separate project).

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.

To solve this error, create crossdomain.xml in the web service project root folder file with below 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>


and you should be able to access this web service from the Silverlight.

Hope this will help.

Thanks

Regards,
Sheo Narayan
http://www.dotnetfunda.com



Responses

Posted by: Kunal09 on: 8/30/2011 [Member] Starter | Points: 25

Up
0
Down
Hi,

You have to add 2 xml files, clientaccesspolicy and crossdomain in your project to resolve this problem.

Thanks,

SheoNarayan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 8/30/2011 [Member] [MVP] [Administrator] NotApplicable | Points: 25

Up
0
Down
nice , you need another File too "clientaccesspolicy.xml" defined like this

<?xml version="1.0" encoding="utf-8"?>

<access-policy>
<cross-domain-access>
<!-- Silverlight 3 or higher requires the http-request-headers attribute. -->
<policy>
<allow-from http-request-headers="*">
<domain uri="http://*" />
<domain uri="https://*" />
<domain uri="*"/>
</allow-from>
<grant-to>
<resource path="/" include-subpaths="true"/>
</grant-to>
</policy>
</cross-domain-access>
</access-policy>


normally these Files goes together

Thank you for posting at Dotnetfunda
[Administrator]

SheoNarayan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: SheoNarayan on: 8/30/2011 [Administrator] HonoraryPlatinum | Points: 25

Up
0
Down
For me in the local machine, it works without adding the clientaccesspolicy.xml file.

Could you both explore more on this?

Regards,
Sheo Narayan
http://www.dotnetfunda.com

SheoNarayan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 8/30/2011 [Member] [MVP] [Administrator] NotApplicable | Points: 25

Up
0
Down
On the Server might need the other file.


Thank you for posting at Dotnetfunda
[Administrator]

SheoNarayan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: SheoNarayan on: 8/30/2011 [Administrator] HonoraryPlatinum | Points: 25

Up
0
Down
I think the clientaccesspolicy.xml is needed only when you are trying to consume the WCF service not Web Service (.asmx).

Regards,
Sheo Narayan
http://www.dotnetfunda.com

SheoNarayan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Dhirajluhana on: 8/26/2013 [Member] Starter | Points: 25

Up
0
Down
Thanks ....

It works for my SharePoint 2010 Web Application which uses the WCF Service.

Thanks ..

--- Dhiraj Luhana


Dhiraj Luhana

SheoNarayan, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response