Access SharePoint Web Services through Silverlight

I have a problem accessing SharePoint Webservice through Silverlight.

An error occurred while trying to query the URI ' http: // sample: 8000 / _vti_bin / Authentication.asmx '. This may be due to an attempt to access the service in cross-domain mode without a proper cross-domain policy in place or a policy that is unsuitable for SOAP services. You may need to contact the service owner to publish the cross-domain policy file and provide its HTTP SOAP-related headers for sending. See Internal Exception for more details.

Some questions:

  • How to deploy clientaccesspolicy.xml correctly through Sharepoint Designer? Just open the site in the designer, add the file, and then publish?
  • The site where clientaccesspolicy.xml is to be deployed uses forms-based authentication. I could not use Sharepoint Designer to publish there. Because of this, I created a new zone for this site that uses Windows authentication and published clientaccesspolicy.xml. Both use the same content database, no?
  • If clientaccesspolicy.xml is published, how to allow access to this file anonymously?

Relations Anton Kalchik

+4
source share
5 answers

Here are the answers to my questions 1. and 2 ..:

  • In Sharepoint Designer, you open the site: File → Open Site → In the text box "Site Name:" enter the URL of your site. Then drag clientaccesspolicy.xml to the root of your site.
  • If you have form authentication, you do not need this step to create a new zone (but for some reason this may be useful). You simply open a web browser and type in the URL of your site. Then fill in the text fields (always with a user with administrator rights) and check the box "Enter me automatically." After that, the Sharepoint developer will use these credentials for the specified URL.

If you can help me with question Nr. 3, or you have another solution, how can I access clientaccesspolicy.xml from Silverlight, post it!

+1
source

The way we handled this in our project was the use of an HTTP handler. We put the clientaccesspolicy.xml file in the _layouts directory (which is shared on sharepoint sites) using the function (you can also just manually copy it there).

Then we added our HTTP handler to the web.config handler section. In our handler, we check if there is a request 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 that this will cost security so that it cannot completely solve your problem. But at least it gives you a way to access this file.

+1
source
  • This is normal.
  • This should be if you have not set up a completely new site.
  • There should not be such a security risk. If you need authentication through WindowsAuth for services, so you should use for clientaccesspolicy.xml.
0
source

Keep in mind that clientaccesspolicy.xml must be in the root directory . In your example, it would have to use http: // sample: 8000 / clientaccesspolicy.xml . If you cannot open it from your browser at this URL, your Silverlight client will also not find it.

The easiest way to get the file in the right place is to simply copy it via FTP or Explorer. The file must be accessible to anonymous users (read-only).

0
source

I find a more realistic way to implement sharepoint httpHandler: it returns all the contents of clientaccesspolicy.xml itself

  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>"); } } 
0
source

All Articles