Over Macho Grande

Sunday, September 10, 2006

Mixing SharePoint and Java

The primary development environment where I work is Java on Unix. However, we've started to move to SharePoint for collaborative development. If you've ever worked with SharePoint from the client side, typically you'll see something like this in your C# code:

someSharePointServiceWebReference.PreAuthenticate = true;
someSharePointServiceWebReference.Credentials = CredentialCache.DefaultCredentials;

Those two lines encompass a lot of activity behind the scenes. Essentially you're asking the .NET framework to authenticate you with an NTLM hash.

All is not lost if you want to do the same thing in Java. Version 3.0 of the Jakarta HttpClient can manage NTLMv1 authentication. Create an instance of org.apache.commons.httpclient.NTCredentials and you're set.

Storing files in a document library is pretty easy. Just use the HTTP "PUT" verb. About the only tricky part is determining the URL to pass to the PutMethod constructor. The URL has to be the URL of the document library plus the desired remote file name.

So, if you access a document library like this:
http://someserver/sites/somesite/Shared%20Documents/Forms/AllItems.aspx
and you want to put a Word doc called "Polices.doc" into it, the PUT URL is this:
http://someserver/sites/somesite/Shared%20Documents/Policies.doc

Next time I'll go over how to use Apache Axis to call a SharePoint webservice.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]



<< Home