WCF for Silverlight Application

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

I tried to add clientaccesspolicy.xml and crossdomain.xml to: wcf project folder iis wwwroot local root of drive E: \

but nothing affects where should I put them?

0


a source to share


6 answers


As you say you don't have a service running under IIS, I'm going to make some assumptions

  • Your silverlight app is hosted in an html page that you double click to load, providing the file: // URI in the browser location bar, or you publish it to your local IIS.
  • A WCF service runs in a process of its own, such as a command line application, Windows service, or Winforms application. Whatever is hosted through it, you will not be at the same URL as your silverlight app.


The silverlight app and wcf service are hosted in separate URLs: app in file: //example.html or http: // localhost if you published it to IIS and wcf service at http: // localhost: 1234 . This causes cross domain access issues because the port numbers are different or you are loading the silverlight application from file: // URI and you are the owner of the WCF service yourself. If you are the owner of the WCF service yourself, you cannot fix this problem because it requires either a clientaccesspolicy.xml file or a crossdomain.xml file to access the services from your Silverlight URL, however there is no way to serve XML from root itself hosting the WCF server.

+1


a source


If you go from context http: // ... to file context: // ... it is not a cross-domain scoping issue. Instead, it is a cross-context issue that is not resolved 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.



+1


a source


Perhaps you haven't restarted IIS after that?

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

0


a source


Mm ... check your script usage if clientaccesspolicy.xml request is sent.

On the other hand, a dummy client-side processing 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 in the same domain (better if you need security in your calls).

0


a source


0


a source


I think this link can help you ...

How to use a WCF service

0


a source







All Articles