WebDAV client sharepoint server
"Andy Chandler" <[email protected]>
| Newsgroups | gmane.comp.jakarta.slide.user |
|---|---|
| Message-ID | <[email protected]> |
Greetings - I'm hoping anyone can help me. I've googled, read
/searched the back archives and I'm still not working. I have to upload
files to Microsoft sharepoint from a java program. Based on my
research I fully expected having to turn of the expect-continue
functionality but apparently I'm doing it all wrong here.
Details:
slide 2.1 client lib
NTLM authentication
Output below is typical:
Uploading 'C:\coLinux\cofs.txt' to 'http://psosupport/Shared
Documents/cofs2.txt'
Dec 10, 2006 11:22:10 PM
org.apache.commons.httpclient.auth.AuthChallengeProcessor
selectAuthScheme
INFO: ntlm authentication scheme selected
Dec 10, 2006 11:22:11 PM org.apache.commons.httpclient.HttpMethodBase
readResponse
INFO: Discarding unexpected response: HTTP/1.1 100 Continue
Dec 10, 2006 11:22:12 PM
org.apache.commons.httpclient.auth.AuthChallengeProcessor
selectAuthScheme
INFO: ntlm authentication scheme selected
Unbuffered entity enclosing request can not be repeated.
Example simple code I've tried to use (I've tried many variations but
this is the current one)
package org.apache.webdav.cmd;
import java.io.File;
import org.apache.commons.httpclient.Credentials;
import org.apache.commons.httpclient.HttpURL;
import org.apache.commons.httpclient.HttpsURL;
import org.apache.commons.httpclient.NTCredentials;
import org.apache.commons.httpclient.URIException;
import org.apache.webdav.lib.WebdavResource;
public class SimpleTest {
public static void main(String[] args) {
String uri = "http://psosupport.visionael.com";
try {
String dest = "http://psosupport/Shared Documents/cofs2.txt";
String src = "c:/colinux/cofs.txt";
File file = new File(src);
if (file.exists()) {
System.out.println("Uploading '" + file.getCanonicalPath()
+ "' to '" + dest + "' ");
WebdavResource webdavResource = null;
try {
NTCredentials creds2 = new NTCredentials("myusername", "mypassword",
"hostname", "ntdomain");// tried both the client hostname and the server
hostname
webdavResource = new WebdavResource(
"http://psosupport/Shared Documents/", creds2);
webdavResource.retrieveSessionInstance()
.getHostConfiguration().getParams().setParameter(
"http.protocol.expect-continue",
Boolean.FALSE);
if (webdavResource.putMethod(file)) {
System.out.println("succeeded.");
}
} catch (Exception e1) {
System.out.println(e1.getMessage());
}
}
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
}