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

 

To fix this:

 

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.

 

4. Reset World Wide Web Publishing Service. You can do that with iisreset command.

 

You can download the clientaccesspolicy.xml and crossdomain.xml at my skydrive.

 

Resources:

Making a Service Available Across Domain Boundaries

About chanmingman

Since March 2011 Microsoft Live Spaces migrated to Wordpress (http://www.pcworld.com/article/206455/Microsoft_Live_Spaces_Moves_to_WordPress_An_FAQ.html) till now, I have is over 1 million viewers. This blog is about more than 50% telling you how to resolve error messages, especial for Microsoft products. The blog also has a lot of guidance teaching you how to get stated certain Microsoft technologies. The blog also uses as a help to keep my memory. The blog is never meant to give people consulting services or silver bullet solutions. It is a contribution to the community. Thanks for your support over the years. Ming Man is Microsoft MVP since year 2006. He is a software development manager for a multinational company. With 25 years of experience in the IT field, he has developed system using Clipper, COBOL, VB5, VB6, VB.NET, Java and C #. He has been using Visual Studio (.NET) since the Beta back in year 2000. He and the team have developed many projects using .NET platform such as SCM, and HR based applications. He is familiar with the N-Tier design of business application and is also an expert with database experience in MS SQL, Oracle and AS 400.
This entry was posted in .Net and tagged . Bookmark the permalink.

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

  1. Pingback: Simplest Asynchronous WCF Service Call sample from Silverlight – C# (Video) | Chanmingman's Blog

  2. EKoshairy says:

    Thanks for your solution.. I tried to place the files in the root of my website but there is no difference.
    I am also a little confused:
    Following from the link u mentioned:
    http://msdn.microsoft.com/en-us/library/cc197955%28VS.95%29.aspx
    It states that the files should be placed
    “at the root of the domain where the service is hosted ”
    I am a little confused esp that I am trying to access exchange online web service on office-365 ,

    Could you please tell me how you got it to work ? Thanks

  3. Ekoshairy says:

    Thx for the reply.
    Yes I made sure it is the folder indeed ..
    I could also access the files for clientaccesspolicy.xml and crossdomainpolicy.xml from the site site root as well.

  4. Ryan says:

    I copied the xml file to the web site root folder, it did not work, at end I figure out the the double quotes (for example “1.0“) in the clientaccesspolicy.xml and crossdomainpolicy.xml files is incorrect, I replace all double quote from “ to “, then it works fine

  5. Swapnil says:

    No…It’s not working…Even I placed the files in the root folder…There seems to be another solution for this

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s