none
WCF Cross-Domain Security Exception Silverlight 4 RRS feed

  • Question

  • I am getting a Communication Exception when trying to access WCF Application from Silverlight from another domain.

    I already know silverlight doesn't normally allow cross-domain calls, but my clientaccesspolicy.xml file should allow it:

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

    Here are HTTP Headers from the call for the file (Taken from Fiddler)

    HTTP/1.1 200 OK
    Date: Mon, 09 Dec 2013 20:59:49 GMT
    Server: Apache/2.2.3 (CentOS)
    Last-Modified: Mon, 09 Dec 2013 20:56:53 GMT
    X-AspNet-Version: 4.0.30319
    Content-Length: 1096
    Cache-Control: private
    X-Powered-By: Mono
    Connection: close
    Content-Type: text/xml

    What could possibly make it fail?

    Monday, December 9, 2013 9:02 PM

Answers

  • Hi,

    Yes, in order to enable a Silverlight control to access a service in another domain, the service must explicitly opt-in to allow cross-domain access. By opting-in, a service states that the operations it exposes can safely be invoked by a Silverlight control, without potentially damaging consequences to the data that the service stores.

    Silverlight  supports two different mechanisms for services to opt-in to cross-domain access:
    1. Place a clientaccesspolicy.xml file at the root of the domain where the service is hosted to configure the service to allow cross-domain access.

    2. Place a valid crossdomain.xml file at the root of the domain where the service is hosted. The file must mark the entire domain public. Silverlight supports a subset of the crossdomain.xml schema

    For more information, please try to see this link for details:
    #Cross domain policy for silverlight to access a WCF Service:
    http://slushanthan.blogspot.in/2011/10/cross-domain-policy-for-silverlight-to.html .

    And please try to debug the application to find some exceptions.

    #Silverlight & WCF Debugging and using Fiddler!:
    http://www.fredmastro.com/post/Silverlight-WCF-Debugging-and-using-Fiddler!.aspx .

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.



    Wednesday, December 11, 2013 9:16 AM
    Moderator