Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I upload a document to SharePoint with Java?

I'm creating some big files (DB exports) with Java and I need to put them somewhere on our SharePoint server. Right now, I'm doing this with IE but I'd like to automate this step, too.

I searched the web and I found some hints to use SOAP but I don't really see to the ground of all this, yet. Can someone provide me with some sample code or a recipe what I need to do?

Please note: the SharePoint server asks for NT domain authentication. I can't even login with Firefox :(

EDIT

  • How do I convert the scary URL in IE into a WebDAV path?
  • Is there a WebDAV "explorer" which I can use before I ruin the production system with my code? I tried "DAV Explorer 0.91" from http://www.davexplorer.org/ but that can't connect (probably because of NT domain auth).
like image 941
Aaron Digulla Avatar asked Nov 24 '08 14:11

Aaron Digulla


2 Answers

In addition to Sacha's suggestions, you can use the SharePoint SOAP web services. Each SharePoint site exposes a bunch of web services via the path http://<Site>/_vti_bin/.

In your case, you probably want the Lists web service (http://<Site>/_vti_bin/Lists.asmx). You can grab the WSDL from http://<Site>/_vti_bin/Lists.asmx?WSDL. The WSS 3.0 SDK has details on how to use the web service (you'll probably want to use the UpdateListItems and AddAttachment methods).

All that said, Sacha's first option (mapping a document library to a drive) is probably the easiest way assuming you can get around the NTLM issues.

If you're using Windows you can simply navigate to a UNC path for a document library. For example, if the browser URL for your document library is:

http://<Site>/Foo/BarDocs/Forms/AllItems.aspx

you can simply type the corresponding UNC path in the Windows Explorer address bar:

\\<Site>\Foo\BarDocs

and then drag and drop files to this location. If you'd like you can map this location to a drive letter using Windows Explorer or the SUBST.EXE command-line utility.

like image 159
dariom Avatar answered Oct 22 '22 07:10

dariom


Okay ... after several hours of work and biting myself through the "documentation" MicroSoft provides and all the hints randomly spread over the 'net, I've managed to write some sample code to browse the content of a SharePoint server: Navigating SharePoint Folders With Axis2.

Next stop: Uploading something.

like image 37
Aaron Digulla Avatar answered Oct 22 '22 07:10

Aaron Digulla