views:

534

answers:

2

The missing link in my IIS7 + Silverlight 3.0 + WCF Service app is the cross domain policy. Are there any instructions on how to create/obtain such a policy. I understand that there are two xml files that need to go in the web root of the app. What do I put in them, how do I format them, does some template exist which indicates which fields need to be filled in? Are there instructions somewhere on msdn which explain how to do this? I'm just about out of possible terms to query google with, any pointers would be appreciated.

Thanks, Brian

+1  A: 

Well, I think this might be the answer, but other answers are certainly welcome for discussion, esp. since we cant close the thread yet anyway...

http://timheuer.com/blog/archive/2008/04/06/silverlight-cross-domain-policy-file-snippet-intellisense.aspx

sweeney
+1  A: 

Silverlight looks for clientaccesspolicy.xml (which is specific to silverlight) if thats not found it will fall back on crossdomain.xml which can also be used by flash for instance. You only need one of those (sockets only work with clientaccesspolicy.xml but webclient and http work with both).

Lets stick with clientaccesspolicy.xml for now since there are less caveats and the crossdomain.xml support was only added to catch up with flash since public services like flickr already have one.

The DTD including description for clientaccesspolicy.xml is at this page on MSDN

this basic example should get your started

<?xml version="1.0" encoding="utf-8"?>
<access-policy>
  <cross-domain-access>
    <policy>
      <allow-from>      
        <domain uri="*"/> <!-- Allows calls from every domain -->
      </allow-from>      
      <grant-to>      
        <resource path="/api" include-subpaths="false"/> <!-- Only allows domain/api? to be called nothing else including api.txt, api/foo etc... -->
      </grant-to>      
    </policy>
  </cross-domain-access>
</access-policy>
olle
ok so, the path attribute of resource should point to the location of what, my compiled dll?
sweeney
to te endpoint of your WCF service. Normally you would have something like http://www.foo.com/api/service. You can also set it to <resource path="/" include-subpaths="true"/> to allow everything on the domain.
olle
hey so this is what i've done and i'm sure im close now, however i still get a CrossDomainError. is there anything else i can check?
sweeney
I would need to see the file and know what kind of calls you are making.
olle