Silverlight 4 WCF "Cross-Domain" error - silverlight

We have a WCF service running on a remote server. It runs as a Windows Service, not hosted in IIS. We can hit this WCF service from our WinForms and WFP apps without any problem. However, when we attempt to hit it from a Silverlight 4 app, we get the following error:
An error occurred while trying to make a request to URI 'http://111.111.111.111/8484/Psn'. This could be due 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. This error may also be caused by using internal types in the web service proxy without using the InternalsVisibleToAttribute attribute. Please see the inner exception for more details.
Could someone put this into English and explain what I might be able to do to satisfy Silverlight?

The first thing to check is that you have a clientaccesspolicy.xml file or crossdomain.xml file on the WCF service host. Either of these files can be used to control which domains have access to your service. Without them no one has any access from Silverlight. These files live in the root of the WCF service host:
If, for example, the service is hosted in http://fabrikam.com then the file must be located at http://fabrikam.com/clientaccesspolicy.xml ... [or] ... http://fabrikam.com/crossdomain.xml.
The following clientaccesspolicy.xml file will allow access from http://www.example.com but block it from everywhere else:
<?xml version="1.0" encoding="utf-8"?>
<access-policy>
<cross-domain-access>
<policy>
<allow-from http-request-headers="SOAPAction">
<domain uri="http://www.example.com"/>
</allow-from>
<grant-to>
<resource path="/" include-subpaths="true"/>
</grant-to>
</policy>
</cross-domain-access>
</access-policy>
A similar crossdomain.xml file would be:
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-http-request-headers-from domain="http://www.example.com" headers="SOAPAction,Content-Type"/>
</cross-domain-policy>
Source

Related

Silverlight clientaccesspolicy.xml

We have Silverlight Application with RIA web service. URL: https://mysite.mydomain.com/services/mysitewebservice.svc
Also, we have a Sharepoint (SharePoint 2013) site hosted in separate domain. URL: https://mysharepointsite.mydomain.com
The Silverlight RIA service is called in SharePoint Silverlight Web Part.
I placed the "clientaccesspolicy.xml" file in the Silverlight root site (URL: https://mysite.mydomain.com/clientaccesspolicy.xml) and I can view this file in IE v11 browser. Compatibility view is ON.
<?xml version="1.0" encoding="utf-8"?>
<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>
But calling the service in SharePoint Site SL Web Part. an exception error still occurs.
"Load operation failed for query 'GetMyData'. An error occurred while trying to make a request to URI 'https://mysite.mydomain.com/services/mysitewebservice.svc/binary/GetMyData?category=sales'. This could be due 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. This error may also be caused by using internal types in the web service proxy without using the InternalsVisibleToAttribute attribute. Please see the inner exception for more details."
I read bunch of forums and articles but they all points to placing the clientaccesspolicy.xml in root site.
What is missing. Please help.

getting crossdomain error in silverlight and clientaccesspolicy 304 error

I need to write some data to the DB from a Silverlight 4 application.
I'm using a Silverlight Enabled WCF Web Service. I've published it to IIS7 and added a ClientAccessPolicy.xml file to the inetpub/wwwroot (among other places) so I can access localhost/ClientAccessPolicy.xml just fine. I also added crossdomain.xml just in case.
I also have a Silverlight4 client app which accesses this service and runs through VS2010 on development server.
When trying to invoke a method in the WebService I'm getting a crossdomain error although I have a crossdomain policy in place and the web service is working fine.
When using Fidler I see I'm getting a 304 error when the client app is trying to access the clientaccesspolicy.xml
If I also publish the client app to IIS7 (both under port 80), I can run it using a browser on the same machine with no problem. But when I try to access it on a different machine, I again get a crossdaomain error.
I tried everything but I can't find an answer for this problem anywhere! Please help!!
This is what my ClientAccessPolicy.xml looks like:
<?xml version="1.0" encoding="utf-8"?>
<access-policy>
<cross-domain-access>
<policy>
<allow-from http-request-headers="SOAPAction">
<domain uri="http://*"/>
</allow-from>
<grant-to>
<resource path="/" include-subpaths="true"/>
</grant-to>
</policy>
</cross-domain-access>
</access-policy>
I have struggled with this misleading error "crossdomain error" before and after reading your situation I can tell for sure that ClientAccessPolicy.xml configuration is not the issue here you should look elsewhere.
few things i would do
Check my client config & web service configs(double check endpoints, behaviours and finally binding protocols) on the silverlight app.
Enable error logging for your wcf service.
Make sure you are passing the right authentication token to your web service (enable anonymous authentication for the web application hosting WCF service)).

WCF RIA Services domain service over https client access policy problems

We have a WCF RIA domain service with
[EnableClientAccess(RequiresSecureEndpoint = true)]
We have the website set to use http and https. We have a client access policy file in the root of the website like this:
<access-policy>
<cross-domain-access>
<policy>
<allow-from http-request-headers="*">
<domain uri="http://*"/>
<domain uri="https://*"/>
</allow-from>
<grant-to>
<resource include-subpaths="true" path="/"/>
</grant-to>
</policy>
</cross-domain-access>
</access-policy>
When we access the Silverlight application over https everything is fine. When we access it over http we get the following error:
Invoke operation 'Working' failed. An error occurred while trying to make a request to URI 'https://localhost/ClientBin/SilverlightApplication3-Web-DomainService1.svc/binary/Working'. This could be due 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. This error may also be caused by using internal types in the web service proxy without using the InternalsVisibleToAttribute attribute. Please see the inner exception for more details.
Which implies that our policy file is incorrect, but can't see what. Any ideas?
The reason that it wasn't working was that we were using a self-signed certificate, generated withe the machine name and then using localhost on the url. The url has to match to ensure that the ssl gets no certificate errors.
A good way to check this was to run the entire site over https and ensure that the browsers do not give a certificate error.

cross-domain policy file error

I am using WCF service (Not RIA) and silverlight I am getting the following error :
An error occurred while trying to make
a request to URI
'http://localhost:8732/'. This could
be due 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. This error may also be caused
by using internal types in the web
service proxy without using the
InternalsVisibleToAttribute attribute.
Please see the inner exception for
more details.
I have tried adding the following to my the clientaccesspolicy.xml file and the crossdomain.xml to the root of my web project. they look like this...
<access-policy>
<cross-domain-access>
<policy>
<allow-from http-request-headers="*">
<domain uri="http://*"/>
<domain uri="https://*"/>
</allow-from>
<grant-to>
<resource include-subpaths="true" path="/"/>
</grant-to>
</policy>
</cross-domain-access>
</access-policy>
crossdomain.xml:
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-http-request-headers-from domain="*" headers="*"/>
</cross-domain-policy>
Any ideas why I am getting this?
Thanks in advance.
If you can't install fiddler, can you download and use TcpTrace? http://www.pocketsoap.com/tcptrace/
The clientaccesspolicy.xml needs to be placed at the root of the website hosting your WCF service and not at the root of your web project.
I ran into this problem with a SOAP WCF service as soon as I moved by WCF service into a separate web app from my Silverlight web app project. Even with my clientaccesspolicy.xml in the WCF web app's root, I was still getting this error. The fastest solution for me was to change my WCF service from SOAP to REST, and then finally Silverlight recognized the clientaccesspolicy.xml and the requests started working again.

Silverlight client access policy problem

I have a wcf webservice which I call from my silverlight application, using https, and it works fine without any problems. Now I got to add a new reference to an old service (soap/asmx) from the silverlight client which went ok. Then when I tried to access the service, I get the following errors:
An error occurred while trying to make a request to URI 'http://localhost/OldService.asmx'. This could be due 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....
Note: that the asmx service is using http instead of https.
My clientaccesspolicy file is as follows:
<?xml version="1.0" encoding="utf-8"?>
<access-policy>
<cross-domain-access>
<policy>
<allow-from>
<domain uri="*"/>
</allow-from>
<grant-to>
<resource path="/" include-subpaths="true"/>
</grant-to>
</policy>
</cross-domain-access>
</access-policy>
I think you need to use only Silverlight enabled service.
Silverlight works only with *.svc services, so you can not use *.asmx service in Silverlight project.
I have solved it actually, I just made them all https.

Resources