sdfgdfg
sdfgdfg

Reputation:

WCF for Silverlight App

I have created a Silverlight 2 appliction, that uses a WCF service. The service is located in a local folder (not IIS) and works fine with a Winforms test. when I try to call the service, it returns with an error: " no pocily for cross domain".

I've tryed to add clientaccesspolicy.xml and crossdomain.xml to: the wcf project folder the iis wwwroot the local drive root E:\

but nothing takes any affect where should i put them?

Upvotes: 0

Views: 644

Answers (4)

Jimmy
Jimmy

Reputation: 28426

If you're going from an http://... context to a file://... context, it's not a cross-domain issue, actually. Instead, it's a cross-context issue, which is not allowed in Silverlight 2 (this also happens with http:// and https://) for security reasons. I'm not sure what the state of this will be in Silverlight 3.

Upvotes: 1

blowdart
blowdart

Reputation: 56550

As you say you don't have the service running under IIS I am going to make some assumptions

  • Your silverlight app is hosted in an html page you load by double clicking, giving a file:// URI in the browser location bar, or you're publishing it to your local IIS.
  • Your WCF service is running in some self hosted process like a command line app, windows service or Winforms application. Whatever it is hosted through it will not be on the same URL as your silverlight app.

The silverlight app and the wcf service are hosted in separate urls, the app on file://example.html or http://localhost if you've published it to IIS and the wcf service on http://localhost:1234. This raises cross domain access problems because the port numbers are different, or you are loading the silverlight app from a file:// URI and you're self hosting the WCF service. If you are self hosting the WCF service you cannot solve this because they require either a clientaccesspolicy.xml file or a crossdomain.xml file allowing access to the services from your silverlight URL, however there is no way to serve an XML from the root of the self hosting WCF server.

Upvotes: 1

Braulio
Braulio

Reputation: 1728

Mm... check using fiddler if the clientaccesspolicy.xml request is sent.

On the other hand, a dummy clientaccesspolicy to check if the connection is working:

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

But, you should try to work on the same domain (better if you need security on your calls).

Upvotes: 0

Moayad Mardini
Moayad Mardini

Reputation: 7341

Perhaps you didn't restart IIS after that?

Edit : Here's a thorough tutorial, make sure you've don't every step to make it work : Silverlight 2.0 and WCF.

Upvotes: 0

Related Questions