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)).
Related
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.
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
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.
I am using silverlight 4 application, in two scenarios.
Scenario 1: Silverlight and RPC on same machine
Being run hosted on a web page on the file system, silverlight XAP is also on the file system:
C:\Silverlight\FSSilverlightApp\bin\Debug\SilverlightApplication2TestPage.html
Connecting to a web site on localhost, being accessed:
https://localhost/rpc/someMethod
These are two separate URI's so the browser detects and immediately requests (track via fiddler):
https://lcoalhost/clientaccesspolicy.xml
sucessfully returns:
<?xml version="1.0" encoding="utf-8"?>
<access-policy>
<cross-domain-access>
<policy>
<allow-from http-request-headers="*">
<domain uri="http://*"/>
<domain uri="https://*" />
</allow-from>
<grant-to>
<resource path="/" include-subpaths="true"/>
</grant-to>
</policy>
</cross-domain-access>
</access-policy>
The application is then able to make the rpc requests (observed via fiddler)
Everything is fine. If i change the remote host to the local machine name instead of localhost, that works fine as well.
Scenario 2: Silverlight on local machine and RPC is remote
In this scenario, I am using a different desktop to access the same RPC server used in scenario 1.
Silverlight starts up, and no request to: clientaccesspolicy.xml is made
Fiddler shows a ton of https tunnels being established, but no commuinication between my machine and the remote server.
The following security exception is returned:
System.Security.SecurityException ---> System.Security.SecurityException: Security error.
at System.Net.Browser.ClientHttpWebRequest.InternalEndGetResponse(IAsyncResultasyncResult)
at System.Net.Browser.ClientHttpWebRequest.<>c__DisplayClass5.<EndGetResponse>b__4(ObjectsendState)
at System.Net.Browser.AsyncHelper.<>c__DisplayClass2.<BeginOnUI>b__0(Object sendState)
--- End of inner exception stack trace ---
at Microsoft.FSharp.Control.WebExtensions.AsyncGetResponse#1781-1.Invoke(Exception _arg1023)
at Microsoft.FSharp.Control.AsyncBuilderImpl.callA#736.Invoke(AsyncParams`1 args)
I assume this is an IE configuration issue. I tried setting the machine in scenario 1, as a trusted site inside of internet explorer and that didn't seem to work... This must be a self signed or mismatched certificate issue. Any thoughts?
Using: IE 8 and Windows 7
Thoughts?
I used Fiddler to sit in between the sliverlight client and the server. IN order to get that to work properly I needed to export the fiddler certificate (tools\fiddlerOptions\https) and install it locally as the root certificate authority.
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.