spyter
spyter

Reputation: 727

Cross Domain Error - Silverlight - WCF self hosted service

I am trying to hit a self hosted WCF service I created that uses HTTPS. I am able to hit the service with WCFClientTest tool and through the web browser however my silverlight application is not working. I am getting the following error:

This could be due to 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.

I do have the clientaccesspolicy.xml in place and I can see the silverlight app is getting it ok when i view it through fiddler. The xml file contains the following:

<access-policy>
<cross-domain-access>
<policy>
<allow-from http-request-headers="*">
<domain uri="*"/>
</allow-from>
<grant-to>
<resource path="/" include-subpaths="true"/>
</grant-to>
</policy>
</cross-domain-access>
</access-policy>

The problem is, even though the silverlight application appears to be requesting AND receiving that file, it is still throwing the error message that it needs to allow cross domain access.. any ideas??

Thanks in advance.

Upvotes: 1

Views: 3019

Answers (2)

Jignesh Thakker
Jignesh Thakker

Reputation: 3698

You need a separate domain node for https:

<domain uri="https://*" /> 

visit for more information on Cros Domain: http://msdn.microsoft.com/en-us/library/dd470115(VS.95).aspx & http://blogs.msdn.com/b/carlosfigueira/archive/2008/03/07/enabling-cross-domain-calls-for-silverlight-apps-on-self-hosted-web-services.aspx

May this link help.

Upvotes: 0

zapico
zapico

Reputation: 2396

Take care with address and port your application is trying to consume WCF Service. Use Fiddler to see where it's calling (I've had many problems like this with that because the error for VS is the same... it doesn't find the Service).

Anyway here you have a clientaccesspolicy.xml that is working:

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

Upvotes: 2

Related Questions