views:

2331

answers:

4

Hello, 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:

  1. How do I correctly deploy clientaccesspolicy.xml over Sharepoint Designer? Simply open site in designer, add file and then publish?
  2. 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 ?
  3. If clientaccesspolicy.xml will be published, how can I allow this file be accessed anonymously?

Regards Anton Kalcik

+1  A: 

Here answers to my question 1. and 2.:

  1. 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.
  2. 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!

AKa
rather use the comment feature (I think it's only available at a certain level though) or use the edit feature to update your post. don't post answers to your own question, unless it is an answer.
Robert MacLean
Point 1. and 2. are answers to my questions.
AKa
A: 
  1. That is fine.
  2. It should be, provided you haven't setup a whole new site somehow.
  3. 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.
Robert MacLean
Why allowing clientaccesspolicy.xml or crossdomain.xml to be accessed anonymously is security risk? Amazon do this also: http://www.amazon.com/crossdomain.xml. Can you provide me sample how can me authenticate before this file will be accessed by Silverlight runtime?
AKa
Part 1: It is a security risk because you are removing the security for a portion of the site. If someone is able to replace that file they could do all kinds of damage.
Robert MacLean
Part 2: Amazon is completely anonymous access in the web server view - they use a custom authentication for their site and services. MOSS is Windows auth for the web server and authentication of site and services. Two very different setups and thus the security issues are different.
Robert MacLean
Part 3: it is normal windows auth, so you just need to assign the credientials property to System.Net.Security.Credentials (or something like that, don't have a Visual Studio around to check - but it should point you on the right path)
Robert MacLean
Question for Part 3: But it is not used the same authentication for web services as for site? I use primary forms authentication instead of windows authentication.
AKa
sorry i missed the part about forms auth. It doesn't change the fact opening a hole in your current security model isn't a good idea. I would assume the username/password would work the same since the credentials handles that for you.
Robert MacLean
As I wrote before I don't really think good idea that I must authenticate only to access clientaccesspolicy.xml.Probably one option will be write some sort of web service wrapper. But I would like to access it directly. If someone have some example how to do it I will be very thankful.
AKa
A: 

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).

AKa
I usually shy away from SP designer, so I can't help you there, but it's certainly possible to simply copy a file to the root of a SP site. It's just a folder on the server (usually c:\inetpub\wwwroot\wss\VirtualDirectories\80), and I've done it a few times myself. Are you limited to using SP Designer for some reason?
Hey Jeff, no I'm not limited to using SharePoint Designer. I already tried you suggestion without success. Look at http://rialight.net/2008/03/18/calling-sharepoint-web-service-from-silverlight-2/. This guy also suggest to use SharePoint Designer.
AKa
A: 

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.

Bryant
Very interesting idea! Exactly today I thank about to use _layouts directory :-)...
AKa