Where to place ClientAccessPolicy.xml for Local WCF Service? - silverlight

I'm trying to create a basic WCF Service and Silverlight client.
I've followed the following tutorial: http://channel9.msdn.com/shows/Endpoint/Endpoint-Screencasts-Creating-Your-First-WCF-Client/
Since Silverlight 4 was incompatible with the WSHttpBinding, I changed it to BasicHttpBinding.
Unfortunately I keep getting this error now: "An error occurred while trying to make a request to URI'**'.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."
I placed clientaccesspolicy.xml in the root directory of the WCF project (which is in the same solution as the Silverlight client). This did not solve the problem.
What do I need to do?

I thnk this is duplicate question :
here are some links , see if any of them helps u :
link text
link text
link text

Related

Silverlight web service query [duplicate]

This question already has answers here:
Silverlight Crossdomain
(13 answers)
Closed 10 years ago.
This error shows me in silverlight page
An error occurred while trying to make a request to URI (/HML.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. 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.
1> Have you looked at the inner Exception? What does it tell you?
2> You should understand what is cross domain access and how cross domain policy could allow it: https://support.ookla.com/entries/21097566-what-is-crossdomain-xml-and-why-do-i-need-it (it is about flash, but it is true for silverlight as well)
Anyway, be more precise about what you try to do? Access an external web service? Call an https part of your website from an http part? This error could occur in a lots of case.

WCF error with hosting of a SL4 Navigation application

I have a SL navigation application, that currently runs on a shared hosting package with a 3rd party ISP. I can login, and register using the ASP.NET membership and role providers.
I have now setup a dedicated server, on which only my app will run. It does not yet have a domain name that points to it... I access it via an IP address.
I've copied the entire site (including the ClientBin and all the XAP's) to the new server, but the Authentication and Registration services don't work... they just return NotFound.
When I check Fiddler on the working site, this service is called :
www.myaddress.com/ClientBin/MyApp-Web-AuthenticationService.svc/binary/Login
which of course succeeds. However, on the other site, the fiddler trace looks the same (because I just copied the site) :
123.123.123.123/ClientBin/MyApp-Web-AuthenticationService.svc/binary/Login
but, the call fails with NotFound. Fiddler reports it as HTTP/1.1 500 Internal Server Error. When I open
http://localhost/ClientBin/MyApp-Web-AuthenticationService.svc/binary/Login
on the server, I get the HTTP/1.1 500, as well as this description :
Handler "svc-Integrated" has a bad module "ManagedPipelineHandler" in its module list
Which leads me to believe that there is something wrong with my IIS config, as the exact same code is working on another system.
What is a "bad module"? How do I fix it?
Normally this type of error is that ASP.Net is not activated or that a handler for svc is not registered or registered correctly.
In your case is looks a bit different. It could be that you have .net framework 4.0 code that you are trying to run in a .net framework 2.0 application pool.
IIS 500 errors often show up with more information in the Windows Event log - if you can somehow get access to that?
Also I've noticed that often the server will actually send debugging output back to the client that everything seems to ignore. Have you checked the entire raw response that is coming back from the server to see if there are any clues there?

Error when calling webservice from silverlight application?

An error occurred while trying to make a request to URI
'http://localhost:42083/Services/MyService.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. 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.
And the most peculiar thing about is that before it worked just fine, but when I changed just
a little thing in a stored procedure it throws this exception. That's weird! I'm getting a little more suspect against SOAP services for now. Anybody who has any ideas?
After having read you comment, please make sure you have deployed a cross-domain policy file. Tim has a great blog about it: http://timheuer.com/blog/archive/2008/04/06/silverlight-cross-domain-policy-file-snippet-intellisense.aspx. It is really an essential asset to obtain when starting SL to server communication.
Hope that helps.

Silverlight 4 HttpWebRequest user agent string is null

The problem
I have a page with a silverlight object. It attempts to retrieve XML from another (external cross domain) page. But I am struggling with a security exception.
I have this code working brilliantly in WPF.
When using a website hosting a silverlight application with the same code, the user agent string of the HttpRequest object is null (and seemingly cannot be set). In fact there is no header information at all - this causes a security exception when attempting to make my asynchronous call.
The question
Why is the user-agent string (and header information) null in my silverlight 4 application when making an asynchronous call using HttpWebRequest?
Thanks in advance!
sounds like you are might be hitting a cross domian issue
does your external xml have a clientaccesspolicy file or a crossdomain file on the site?
http://msdn.microsoft.com/en-us/library/cc197955(VS.95).aspx
Also what is the exception ? can you post.
Update:
OK, Have looked and run your code and yes it a crossdomian issue. The site "http://eu.wowarmory.com/" has a crossdomian file but only allow access from the sites listed in that file ? is you site one of those ? If not you are hitting crossdomain security. (WPF runs on the full CLR and so does not have these restrictions.)
There are options ...
-Silverlight 4 running in elevated trust is one - but that is OOB
-Doing it in Javascript and the passing the data into Silverlight
-Get you server to do the work for you i.e. proxy
-Get them to change the crossdomain file !
There are others it really depends on what you are trying to achieve overall? can you explain more ?

Accessing SharePoint Web Services over Silverlight

I have a problem to access SharePoint Webservice over Silverlight.
An error occurred while trying to make a request to URI
'http://sample:8000/_vti_bin/Authentication.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. 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.
Please see the inner exception for
more details.
Some questions:
How do I correctly deploy clientaccesspolicy.xml over Sharepoint Designer? Simply open site in designer, add file and then publish?
The site where clientaccesspolicy.xml should be deployed use forms authentication. I wasn't able to use Sharepoint Designer to publish there. Because of that, I created new zone for this site, which use Windows Authentication and published clientaccesspolicy.xml there. Both use same content database, didn't ?
If clientaccesspolicy.xml will be published, how can I allow this file be accessed anonymously?
Regards
Anton Kalcik
Here answers to my question 1. and 2.:
In Sharepoint Designer you open the site over: File -> Open Site -> In text field "Site name:" type URL of your site. Than drag & drop clientaccesspolicy.xml in root of your site.
If you have Form Authentication, you don't need for this step create new zone (but for some reasons it can be useful). You simply open web browser and type URL of your site. Then fill up text fields (always with user that have administrator privileges) and check "Sign me in automatically". After that will Sharepoint designer use this credentials for specified URL.
If you can help me with question Nr. 3, or you have some other solution, how can I access clientaccesspolicy.xml from Silverlight, post it!
The way we handled this on our project was to use an HTTP Handler. We put the clientaccesspolicy.xml file in the _layouts directory (which is shared across sharepoint sites) using a feature (you can also just manually copy it there).
Then we added our HTTP handler to the web.config handlers section. In our handler we check to see if the request is for /clientaccesspolicy.xml and if so we rewrite the path:
if (path.ToLowerInvariant() == "/clientaccesspolicy.xml")
{
HttpContext.Current.RewritePath("/_layouts/clientaccesspolicy.xml");
}
I'm not sure if this will bypass the security so it might not fully address your issue. But at least it gives you a method to access this file.
That is fine.
It should be, provided you haven't setup a whole new site somehow.
It shouldn't be as that would be a security risk. If you need to authenticate via WindowsAuth for the services so should you for the clientaccesspolicy.xml.
Keep in mind that clientaccesspolicy.xml must be at the domain root. In your example it would have to availble from http://sample:8000/clientaccesspolicy.xml. If you can't open it from your browser at that URL, your Silverlight client won't find it either.
The easiest way to get the file in the right place is to just copy it there via FTP or explorer. The file should be available to anonymous users (read only of course).
I find more realeable way to implement sharepoint httpHandler: it returns all content of clientaccesspolicy.xml himself
public void ProcessRequest(HttpContext context) {
if (context.Request.Path.ToLowerInvariant() == "/clientaccesspolicy.xml") {
context.Response.Write(#"<?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> "+
#"</cross-domain-access> </access-policy>");
}
}

Resources