0
votes

I have a silverlight application which has some calls to a WCF service. Both silverlight and WCF are located on the localhost. when I run the silverlight application but it fails in the calls to WCF in communication exception. Iv'e understand fron the web that this can be because the WCF and silverlight are not running on the same port and I have to add clientaccesspolicy.xml file. but I didn't understand what is the "domain root" I have to locate there the xml. can you please inform me the path I have to locate the xml there (on localhost)

thanks!

3

3 Answers

1
votes

"Domain root" is the root address of the HTTP domain you are hosting the Silverlight app at. This is a bit counter-intuitive, but remember the policy file is dealing with cross-domain scripting issues.

So if for any of these:

http://www.yourdomain.com

http://www.yourdomain.com/app

http://www.yourdomain.com/app1/PageSilverlightNeedsToHit.aspx

http://www.yourdomain.com/app1/Service1.svc

http://www.yourdomain.com/apps/yourapp/folders/services/versions/otherlongnames/

You have to have a valid clientaccesspolicy.xml at

http://www.yourdomain.com/clientaccesspolicy.xml

An easy test is to hit that url (http://www.yourdomain.com/clientaccesspolicy.xml) from a broswer and ensure you get the access XML back. This will mimick Silverlight's behavior.

If this isn't possible for your hosting setup, please respond. There are other options (custom iis handler, etc) for this request, but depending on your needs they can be overkill.

0
votes

I just did this yesterday with an IIS hosted WCF service. I put the XML file in c:\inetpub\wwwroot(I think. It is on my machine at work).

If you are not IIS hosted, it might be different. When I was first developing my service, I did so as a self hosted exe. In that case, I did not use an XML file. Instead, I implemented another "service" in my self-hosting exe project. The service automatically created the XML file. I don't have the details handy. I can post more info on Monday if you have not solved your problem by then.

In the meantime, see this link:

Where to place ClientAccessPolicy.xml for Local WCF Service?

Or this one:

How can I get my WCF service's client access policy operation to be accessible from the root?

0
votes

Add clientaccesspolicy.xml to your silverlght hosting project in Visual Studio, for instance, MyProject.Web. Is short, place it near Web.config of your application.