Thursday, December 20, 2012

WCF cross-domain policy security error

WCF cross-domain policy security error

I am using VSTS 2008 + C# + WCF + .Net 3.5 + Silverlight 3.0. I host Silverlight control in an html page and debug it from VSTS 2008 (press F5, then run in VSTS 2008 built-in ASP.Net development web server), then call another WCF service (hosted in another machine running IIS 7.0 + Vista). The WCF service is very simple, just return a constant string to client.

When invoking the WCF service from Silverlight, I got the following error message,

An error occurred while trying to make a request to URI 'https://LabTest/Test.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. This error may also be caused by using internal types in the web service proxy without using the InternalsVisibleToAttribute attribute. Please see the inner exception for more details.

Here is the clientaccesspolicy.xml file, anything wrong?

<?xml version="1.0" encoding="utf-8" ?> <access-policy>   <cross-domain-access>     <policy>       <allow-from  http-request-headers="*">         <domain uri="*">         </domain>       </allow-from>       <grant-to>         <resource path="/" include-subpaths="true"></resource>       </grant-to>     </policy>   </cross-domain-access> </access-policy> 

thanks in advance, George

Answers & Comments...

Answer: 1

This may be a shoot in the dark. But I recall running into a similar scenario setting up a WCF service locally on vista and IIS7. as it turned out i had to add some lines into my web.config file more specifically with the baseAddressPrefixFilters, Read this other post : Here . I had a problem because my default website had more than one host binding. it would take *:80 and www.mydomain.com:80 and WCF would not like that.

by : Jorgehttp://stackoverflow.com/users/0

Answer: 2

I had a similar problem but my solution was a lot simpler. In my clientConfig file, my end point addresses for my different services had different URL's. Some had local host and some had my machine's name in the URL. Once I made all of them use local host it fixed my problem.

by : Quintonnhttp://stackoverflow.com/users/518404

Answer: 3

one idea could be to use fiddler and find the request which is requesting crossdomainpolicy xml. Is that failing? Check the address it is pointing to. I debugged my issue using that. It was pointing to root of the server and my crossdomainpolicy xml was in WCF project folder.

by : smilealdwayhttp://stackoverflow.com/users/446489




No comments:

Post a Comment

Send us your comment related to the topic mentioned on the blog