Sliding into WebDAV
by Andrew Anderson12/23/2003
Apache's Jakarta project offers all kinds of great open source resources to Java developers. One of Jakarta's less well-known but extremely useful subprojects is Slide. Slide is composed of a number of different modules, all tied together using the WebDAV protocol. These modules include implementations of a number of useful features such as a WebDAV client library, a WebDAV server library, and a WebDAV-based content management system. Among other uses, these modules give developers the ability to add WebDAV client functionality to their Java applications.
This article gives an introduction to using the Slide WebDAV client functionality in Java applications. The article will start with an overview of the WebDAV protocol, followed by an overview of the Slide project. Finally, we will get our hands dirty with some examples of using the Slide WebDAV client libraries in your applications.
WebDAV
WebDAV stands for "Web-based Distributed Authoring and Versioning." WebDAV is a set of extensions to the HTTP protocol that allows users to collaboratively edit and manage files on remote servers. While the protocol extensions themselves are simple and easy to use, the power that they add to an HTTP server is incredible. In effect, WebDAV makes an HTTP server an advanced remote file system. While protocols such as FTP have provided similar capabilities for years, WebDAV's features go beyond those that are in the standard FTP protocol, and therefore allow developers to use WebDAV to create more powerful applications.
While the implementations of various WebDAV servers offer different levels of protocol support, the following features are generally available and are what set WebDAV apart from protocols such as FTP:
- HTTP-based: Allows all of the advantages of HTTP (file permissions, faster transfers, HTTPS support, etc.).
-
put: The ability to upload resources to a server. -
lock: The ability to set/unset connection-independent, long-duration exclusive and shared locks on resources. - Properties: The ability to store arbitrary metadata for resources.
- Namespace manipulations: The ability to move files, copy files, create directories and list directories.
These features allow the development of all sorts of interesting applications, including distributed web-page authoring/editing applications, version control applications, mail servers, and distributed calendaring applications, just to name a few. When developers combine WebDAV with the "Write Once, Run Anywhere" capabilities of Java, writing multiplatform distributed client applications becomes very simple.
WebDAV Tools and Resources
Like HTTP, WebDAV requires both client and server components. In addition to the Slide project, which provides binaries and libraries for both clients and servers, there are plenty of WebDAV components available:
- The
mod_davApache module adds WebDAV capabilities to Apache (included in Apache 2). - Microsoft's Internet Information Server includes WebDAV server support.
- Mac OS X allows mounting of WebDAV servers as network disks.
- The iDisk offered by Apple's .Mac service uses WebDAV servers, and the iCal program uses WebDAV to publish calendars.
More information on WebDAV (including information on mod_dav) is available from The WebDAV Resources Page.
The Slide Project
As we said earlier, the Slide project's home page describes Slide as "a project composed of multiple modules tied together using WebDAV." These "multiple modules" include:
- A content management system with a Java API.
- A servlet implementing the WebDAV protocol on top of the content management system.
- A Java WebDAV and HTTP client library.
- A WebDAV command-line client.
- WebDAV-enabled Swing components (this module is on the features list but not yet implemented).
Like all Jakarta projects, Slide is available in both binary and source distributions. The binary distribution includes all of the classes needed to implement the WebDAV client examples in this article, and is available at Jakarta's binary download page. The binary distribution also includes the binaries for the server, the documentation for Slide, and the JavaDoc for the WebDAV client and server classes. While the binary distribution includes everything that you need for the examples in this article, the source distribution includes the Java source for the Slide's WebDAV command-line client. This file offers insight into coding WebDAV clients with Slide and may be worth checking out. The source distribution is available at Jakarta's source download page.
Once you have the binary distribution downloaded and unzipped, check out client/lib. This directory contains all .jar files needed for the examples in this article, including the Slide WebDAV client libraries and the .jars for several additional libraries that the WebDAV client uses. (The additional libraries are all either distributed by Apache via their Apache license, or are distributed by Sun as part of the Java distribution.) The JavaDoc for the WebDAV client libraries is available in doc/clientjavadoc.
Using Slide
Now down to business: using the Slide WebDAV client libraries to connect to WebDAV servers. The Slide client library encapsulates almost all of the functionality we need to access a WebDAV server in the WebdavResource class. Accessing a WebDAV server involves three basic steps:
- Open a connection to a WebDAV server.
- Issue protocol requests and receive responses from the server.
- Close the connection.
Opening the connection to a WebDAV server is handled via the WebdavResource's constructor. There are several ways to handle this; the most straightforward is to give the constructor an org.apache.util.HttpURL object that contains the URL for the server and user information.
Once the connection is established, we can issue protocol requests across the connection. These protocol request's are handled by a number of methods in WebdavResource, specifically:
aclfindMethod: Used to find Access Control Lists; not implemented in many WebDAV servers.aclMethod: Used to set Access Control Lists; not implemented in many WebDAV servers.copyMethod: Copies a resource from one location to another on the server.deleteMethod: Deletes a resource from the server.getMethod: Gets a resource from the server (the same as the HTTPGETcommand).headMethod: Gets the header of a resource from the server (the same as the HTTPHEADcommand).list: Lists the resources in the current directory of the server.lockMethod: Locks a resource on the server.mkcolMethod: Makes a collection (i.e., a folder or directory) on the server.moveMethod: Moves a resource from one location to another on the server.optionsMethod: Retrieves the options that this server supports (thegetDavCapabilities()andgetAllowedMethods()methods also handle this functionality).postMethod: Gets a resource from the server via an HTTP post (the same as the HTTPPOSTcommand).propFindMethod: Retrieves a resource's properties.propPatchMethod: Sets and edits a resource's properties.putMethod: Puts a resource onto the server (similar to the FTPPUTcommand).setPath: Sets the current path of the remote server.unlockMethod: Unlocks a resource on the server.
Note: Some of Slide's documentation is weak. While this article will cover some of these methods, we will not go over all of them. Some of those we do not cover are especially poorly documented; the best source of information on these methods is the WebDAV protocol documents and plain old-fashioned experimentation.
WebdavResource has a number of other methods that perform a variety tasks; for full details, check out the online version of the WebDAV Client JavaDoc for more details.
Once you are done issuing your protocol requests, then you need to close the WebDAV connection. This is handled by WebdavResource's close() method.
A Simple Example
The simplest Slide WebDAV client program that you can write would do the following:
- Open a connection.
- Get a file.
- Close the connection.
Really, this example is almost too simple, since this can be handled using classes from the java.net package. What this example gives us, though, is an overview of using the WebdavResource class and a structure for later examples.
Here is the code:
// Slide Simple WebDAV client example
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import org.apache.commons.httpclient.HttpException;
import org.apache.util.HttpURL;
import org.apache.webdav.lib.WebdavResource;
public class SlideTest {
public static void main (String args[])
{
try
{
HttpURL hrl =
new HttpURL("http://webdav-server");
hrl.setUserInfo("user","pass");
WebdavResource wdr =
new WebdavResource(hrl);
File fn = new File("remote-file");
wdr.getMethod(fn);
wdr.close();
}
catch(MalformedURLException mue)
{
}
catch(HttpException he)
{
}
catch(IOException ioe)
{
}
}
}
As you probably guessed, the real work of this example happens in the try-catch block. The first two lines set up the HttpURL object, which contains all of the connection information. Then we create a WebdavResource from the HttpURL, which connects to the server. After this, we create a File object to represent where we want the downloaded file to go. The getMethod() gets the file, and close() closes the connection. (Keep in mind that this is only an example, and the exception handling in this code is naive and can leave connections open.)
As you can see using WebdavResource is very straightforward and elegantly handles the various portions of the protocol. Changing this example to handle uploading a file is straightforward, as well. All we need to change are a few lines, as follows:
File fn = new File("local-file");
wdr.putMethod(fn);
Admittedly, changing the file name is superficial, but it is important to note that this line now needs to point to a local file as opposed to a remote file.
These examples are simplistic, but they illustrate how to use WebdavResource to access WebDAV servers. In the next section, we will explore a more complex example that will show how to use WebDAV's locking and unlocking features.
More Complex Examples
Let's say that we have a web site that is maintained by two teams of developers, separated by several time zones. Both teams have responsibility for editing HTML sources on a fairly static web site, and the site administrator wants to prevent them from simultaneously updating files and overwriting each other's changes (remember, this is an example; of course it would be better to use a version control system for this sort of application). In other words, we want to be able to upload, download, lock, and unlock files. We also want our locks to work between connections, in case we log out or are disconnected for whatever reason.
To facilitate this process, we want a class that handles:
- Opening connections
- Listing files
- Locking files
- Downloading files
- Uploading files
- Unlocking files
- Closing connections
We already know how to open a connection, close a connection, upload a file, and download a file, so what we need is code to handle the locking, unlocking, and listing of files. We will assume that the class has an instance variable called wdr that is a WebdavResource and an instance variable path that is a String.
First, we want to be able to lock a file. We will do this with the lockMethod, as well as some other methods for error checking. You will also notice that we are setting the path of the WebdavResource to the file, which we did not have to do with the get and put methods. This is because certain methods, including isCollection, getPath, and setPath, are only supported if the current path is the file we want to work with. Others, like getMethod (but not getMethodData and getMethodDataAsString), do not support this interface. Yes, it is confusing at times.
Here is the code for locking a file:
public boolean lockFile(String filename)
throws Exception
{
// check to make sure current path is a
// directory not a file make sure your initial
// path contains a trailing "/" or else it is
// considered a file!!
if (!wdr.isCollection())
throw new Exception("Path is currently a file");
String currentPath = wdr.getPath();
wdr.setPath(currentPath + "/" + filename);
if (wdr.isLocked())
{
return false;
}
boolean returnVal = wdr.lockMethod();
wdr.setPath(currentPath);
return returnVal;
}
The unlockFile() method is identical, except that we call unlockMethod() on the WebdavResource.
Listing the files in the current directory is handled by the listFiles() method. Note in this example that again we check to make sure that we have the correct type of path.
public String[] listFiles () throws Exception
{
if(!wdr.isCollection())
throw new Exception ("Path is currently a file");
return wdr.list();
}
Using these three methods as a base, adding methods that implement put, get, and/or post, we would have a fairly comprehensive class for interactively editing documents. Throw some Swing components on top of it, and you've got an interactive editing program.
Final Thoughts
Jakarta's Slide project makes adding WebDAV client functionality to Java applications a cinch. The libraries are open source, easy to use, and easy to integrate into all sorts of applications. While Slide's documentation leaves something to be desired, overall, Slide is a winner and makes adding WebDAV client capabilities to a Java programs a reality.
Andrew Anderson is a software developer and consultant in Chicago who's been using and programming on the Mac as long as he can remember.
Return to ONJava.com.
You must be logged in to the O'Reilly Network to post a talkback.
Showing messages 1 through 45 of 45.
-
WebDAV updateMethod(String a, String b)
2007-09-17 05:46:07 Madhavee [Reply | View]
Boolean b = WebDavResObj.updateMethod(String path, String destination) always returns false to me. I think I am passing incorrect arguments... Can anyone expand on the parameters to be passed in this method??
-
Sample Working WebDAV code
2007-01-09 10:49:05 fayazkm [Reply | View]
I have some working code here that might be of help. I had an invocation to the delete method that always returned false but i believe that is because the WebDAV server does not support the delete method. I will post an update when i get it to work. The following code will list, download and upload files.
private void pickup() throws Exception {
String url = "https://vnet.visa.com.ar/webdav/Bandeja de Entrada/HOMOLOGACIONVASA/";
HttpsURL hrl = new HttpsURL(url);
// webdav server login username & password
hrl.setUserinfo("username", "password");
System.out.println("User/Password set.");
Credentials cred = new UsernamePasswordCredentials("proxyuser", "proxypassword");
wdr = new WebdavResource(hrl, "proxyaddr", 443, cred);
wdr.setDebug(3);
String wdrpath = wdr.getPath();
WebdavResource wdrfile = null;
HttpsURL hrlfile = null;
// get list of files
String files[] = listFiles();
// for downloading
for (int i = 0; i < files.length; i++) {
System.out.println(files[i]);
if (files[i].indexOf("A_PPI_modificacion_periodos.txt") != -1) {
File f = new File("C:/" + files[i]);
hrlfile = new HttpsURL(url + files[i]);
hrlfile.setUserinfo("username", "password");
wdrfile = new WebdavResource(hrlfile, "proxyaddress", 443, cred);
wdrfile.getMethod(f);
System.out.println("wdrfile.getStatusCode()="+wdrfile.getStatusCode());
System.out.println("wdrfile.getStatusMessage()="+wdrfile.getStatusMessage());
long time = wdrfile.getGetLastModified();
System.out.println(time);
Date date = new Date(time);
System.out.println(date + "|||||" + date.getTime());
System.out.println("File " + files[i] + " downloaded.");
//boolean deleted = wdrfile.deleteMethod();
//System.out.println("wdrfile.getStatusCode()="+wdrfile.getStatusCode());
//System.out.println("wdrfile.getStatusMessage()="+wdrfile.getStatusMessage());
//System.out.println("File deletion returned "+deleted);
wdrfile.close();
}
}
wdr.close();
}
public String[] listFiles() throws Exception {
if (!wdr.isCollection())
throw new Exception("Path is currently a file");
return wdr.list();
}
private void dropOff() throws IOException {
// another way for uploading
HttpsURL hrl = new HttpsURL("url");
System.out.println("HttpsURL created.");
hrl.setUserinfo("username", "passowrd");
System.out.println("User/Password set.");
Credentials cred = new UsernamePasswordCredentials("proxyuserid", "proxypassword");
wdr = new WebdavResource(hrl, "proxyaddress", 443, cred);
wdr.setDebug(3);
System.out.println("WebdavResource created.");
String wdrpath = wdr.getPath();
String filename = "A_Test_1.txt";
String file = "C:/" + filename;
File f = new File(file);
System.out.println("File object created.");
String path = wdrpath + filename;
System.out.println("wdrpath=" + wdrpath);
System.out.println("path=" + path);
boolean rslt = wdr.putMethod(path, f);
System.out.println("Result of upload is " + rslt);
wdr.close();
}
-
exchange
2006-10-09 06:03:15 amgad2002 [Reply | View]
how to use wedav to send email through exchange server
-
WebDAV & NTLM:Hi i am facing a problem to connect to MSSharePoint 2003 portal server
2006-09-22 00:19:19 sureshvarma [Reply | View]
I tried the following code to connect to Microsoft SharePoint 2003 PortalServer.
NTCredentials creds = new NTCredentials(userName, password, hostAdd, domain );
HostConfiguration hostConfig = new HostConfiguration();
hostConfig.setHost(hostAdd);
HttpURL host = new HttpURL("http://" + hostUrl);
host.setUserinfo(username,password);
WebdavResource res = new WebdavResource(host, (Credentials)creds, WebdavResource.DEFAULT, DepthSupport.DEPTH_1);
And I am getting HttpException like below..
org.apache.commons.httpclient.HttpException
at org.apache.webdav.lib.WebdavResource.propfindMethod(WebdavResource.java:3467)
at org.apache.webdav.lib.WebdavResource.propfindMethod(WebdavResource.java:3423)
etc..
It is very urgent for me,please help me.
Thanks in advance
Regards
Suresh Varma
-
WebDAV & NTLM:Hi i am facing a problem to connect to MSSharePoint 2003 portal server
2007-02-12 09:20:56 PabloMosquera [Reply | View]
Hi, Im having the same problem with the same httpException. I´m trying to connect to a IIS server and I use the same code. Please tell me how you solved the problem
Thanks -
WebDAV & NTLM:Hi i am facing a problem to connect to MSSharePoint 2003 portal server
2008-07-25 05:47:52 httpclient.HttpException [Reply | View]
Hi, Im having the same problem with the same httpException. I´m trying to connect to a IIS server and I use the below code. Please tell me how you solved the problem
public static boolean fileUpload(String localfilepath,String url,String destfolder,String destfile)
{
boolean success=false;
try
{
File file = new File(localfilepath);
BufferedImage image = ImageIO.read(file);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ImageIO.write(image, "bmp", bos);
byte byteArr[] = bos.toByteArray();
bos.close();
HttpURL hrl =new HttpURL(url);
//hrl.setUserinfo("uname","password");
WebdavResource wdr =new WebdavResource(hrl);
success = wdr.putMethod("/"+destfolder+"/"+destfile, byteArr);
wdr.close();
System.out.println(success);
}catch(Exception ex)
{
ex.printStackTrace();
}
return success;
}
My IIS server is running in windows server 2003 platform.and i will get the exception below.
org.apache.commons.httpclient.HttpException
at org.apache.webdav.lib.WebdavResource.propfindMethod(WebdavResource.java:3467)
at org.apache.webdav.lib.WebdavResource.propfindMethod(WebdavResource.java:3423)
at org.apache.webdav.lib.WebdavResource.setNamedProp(WebdavResource.java:967)
at org.apache.webdav.lib.WebdavResource.setBasicProperties(WebdavResource.java:912)
at org.apache.webdav.lib.WebdavResource.setProperties(WebdavResource.java:1894)
at org.apache.webdav.lib.WebdavResource.setHttpURL(WebdavResource.java:1301)
at org.apache.webdav.lib.WebdavResource.setHttpURL(WebdavResource.java:1320)
at org.apache.webdav.lib.WebdavResource.setHttpURL(WebdavResource.java:1408)
at org.apache.webdav.lib.WebdavResource.<init>(WebdavResource.java:290)
------------------------------------------------
But the same above code work successfully by connecting the IIS server which is running in WindowsXP platform. Please Suggest the solution and help me. Thanks a lot.
By Saravanan.K
-
get all directories/files from given path on webDav server
2006-09-13 21:44:41 Khaled-H [Reply | View]
Hello ..
I'm trying to get the directories/files that I have already created on WebDav ..
I'm using the CollectionScanner and Included = {"**"} and excludes = null;
but it seems it's not able to scan and I get nothing ..
May be anyone can help or has a better idea to get my Directories/Files on Webdav.
Thanks in advance.
Khaled
-
put method always return false
2006-08-30 00:37:37 tbspl [Reply | View]
Hi can somebody tell me urgently..i m trying to upload files on a remote webdav server location and i m using this code:
HttpURL hrl = new HttpURL("http://webdav.propco.co.uk/");
WebdavResource wdr = new WebdavResource(hrl);
File fn = new File("D:\\Login.java");
System.out.println(wdr.putMethod(fn));
wdr.close();
There is not any password validate placed on the webdav location and i am able to get list of files from there.But not able to put or get or delete any file on the location. Please reply urgent if somebody can help me in this case.
regards:
bhavesh@propco.co.uk
-
put method always return false
2006-08-30 00:36:50 tbspl [Reply | View]
Hi can somebody tell me urgently..i m trying to upload files on a remote webdav server location and i m using this code:
HttpURL hrl = new HttpURL("http://webdav.propco.co.uk/");
WebdavResource wdr = new WebdavResource(hrl);
File fn = new File("D:\\Login.java");
System.out.println(wdr.putMethod(fn));
wdr.close();
There is not any password validate placed on the webdav location and i am able to get list of files from there.But not able to put or get or delete any file on the location. Please reply urgent if somebody can help me in this case.
-
nice articale
2006-07-13 05:03:15 Ankur.Bhargava [Reply | View]
This is very usefull artical which provide a scrach info to new WebDAV users. the real gud thing is the examples but i was expecting some more examples . i searched the net for examples but i cudnt found any i need some simple example throgh which any new novice developer can feel comphortable Expecting more examples in ankother article
-
Does Microsoft Share point server support Web DAV protocol for file transfer
2006-06-18 21:52:04 gangoo123 [Reply | View]
I have a requirement where I have to upload the documents on Microsoft Share Point Server from a Java Application. And also access those files.
So my query is "Does Microsoft Share point server support Web DAV protocol for file transfer?"
If yes then are there any JAVA API's to do that?
-
How i can i calculate the hit count of a web site that dont have sessions
2006-04-17 01:28:57 sham80 [Reply | View]
I want to calaculate the hit count of a web site that dont use sessions.i also want to use lock for providing mulitipile access
-
SSL
2006-01-17 14:05:40 ksk385 [Reply | View]
Is there a way to configure the WebResource to use Secure HTTP????
I dont want to send my credentials over the internet w/o encryption.
Thanks in advance....
Karan
-
GET
2005-11-09 16:47:27 vballarta [Reply | View]
HI I HAVE THIS CODE TO PUT FILES..IT 'S WORK BUT IN MY COMPUTER SERVER(PUT FILES FOR EXAMPLE LOCATED IN C:) NO WORK IN CLIENTS MACHINE..HOW CAN I DO TO INDICATE THAT I LIKE TO PUT FILES FROM MY DRIVE DISK OF MY CLIENT MACHINE ??
HttpURL hrl =
new HttpURL("http://localhost:8080/slide/files/JPR/fluyo");
hrl.setUserInfo("fluyo","fluyo");
WebdavResource wdr =new WebdavResource(hrl);
String filename = ruta.substring(3);
String unidad =ruta.substring(0,2);
File fn = new File(unidad +"/"+filename);
String path = wdr.getPath() + "/" + filename;
wdr.putMethod(path,fn);
-
Can not Find org.apache.util.Http
2005-11-01 08:26:22 newpieWebDAV [Reply | View]
Hi, this is a stupid question.
I can not find which jar file include
org.apache.util.Http package.
Thanks
-
WebDav & NTLM
2005-07-10 07:52:10 Yensen [Reply | View]
Need Help!!!
1. Are there codes to handle NTLM connection?
I am sending the request to IIS (Windows 2003 Server), when I run the codes,
HttpURL hrl = new HttpURL(mySite);
hrl.setUserinf(myUserName,myPassword);
The response is
WARNING: Credentials cannot be used for NTLM authentication: org.apache.commons.httpclient.UsernamePasswordCredentials.
2) How do you set up the webdav accounts for for extranet users??
Thanks in advance
Yensen
-
WebDav & NTLM
2005-08-01 07:01:16 bwandrack [Reply | View]
Yensen,
Can't help with #2, but I am currently using NTLM and WebDav. Here is some sample code that should help:
NTCredentials creds = new NTCredentials(userName, password, hostAdd, "" );
HostConfiguration hostConfig = new HostConfiguration();
hostConfig.setHost(hostAdd); //Not url, just ip address or fully qualified DN
HttpURL host = new HttpURL("http://" + hostUrl);
WebdavResource res = new WebdavResource(host, (Credentials)creds, WebdavResource.DEFAULT, DepthSupport.DEPTH_1);
Hope this helps.
Bill Wandrack
-
WebDav & NTLM
2007-02-12 09:30:59 PabloMosquera [Reply | View]
Hi, Im facing the same problem. Im trying to connect to a IIS server and I use the NTCredentials code. I have these exceptions.
org.apache.commons.httpclient.HttpException
at org.apache.webdav.lib.WebdavResource.propfindMethod(WebdavResource.java:3467)
at org.apache.webdav.lib.WebdavResource.propfindMethod(WebdavResource.java:3423) -
WebDav & NTLM
2007-02-12 09:27:25 PabloMosquera [Reply | View]
Hi, Im having the same problem with the same httpException. I´m trying to connect to a IIS server and I use the same code. Please tell me how you solved the problem
I have these exceptions
org.apache.commons.httpclient.HttpException
at org.apache.webdav.lib.WebdavResource.propfindMethod(WebdavResource.java:3467)
at org.apache.webdav.lib.WebdavResource.propfindMethod(WebdavResource.java:3423)
...
Thanks -
WebDav & NTLM
2005-09-19 03:34:29 dennis_surendar [Reply | View]
Bill,
Tried with the code given above:
NTCredentials creds = new NTCredentials(userName, password, hostAdd, "" );
HostConfiguration hostConfig = new HostConfiguration();
hostConfig.setHost(hostAdd); //Not url, just ip address or fully qualified DN
HttpURL host = new HttpURL("http://" + hostUrl);
WebdavResource res = new WebdavResource(host, (Credentials)creds, WebdavResource.DEFAULT, DepthSupport.DEPTH_1);
However, I see an authentication-warning message saying "Already tried to authenticate with null authentication realm at <exchange server name>, but still receiving: HTTP/1.1 401 Access Denied". Proceeding furhter with the method "WebdavResource.list ();" gives a NullPointerException.
Am I doing something wrong? Do I need to setup my Tomcat to redirect the authentication to MS Exchange server? Please help.
Thanks in advance.
- Dennis. -
WebDav & NTLM
2005-09-20 04:27:52 dennis_surendar [Reply | View]
Bill,
Finally I solved the puzzle.
Before trying with the above code snippet, I tried to access my Exchange server through Outlook Web Access (OWA) from my browser. While doing so, the browser saved the prompted user-id (Administrator) and password in the password manager.
Hence, for the next time, when I tried to connect to the Exchange server using your code snippet, I got the following error message -
"Already tried to authenticate with null authentication realm at ${Exchange server name}, but still receiving: HTTP/1.1 401 Access Denied".
To overcome this, I just cleared the saved passwords in the browser settings. After doing so, the program works like a charm...!
Thank you.
Regards,
Dennis.
-
Problem in runnign the sample code
2005-05-24 23:46:40 nageshever [Reply | View]
Hi!
when i tried to run the compiled code obtained with slide client, I am getting the below exception. Please help me. thanks in advance.
May 25, 2005 12:13:37 PM org.apache.commons.httpclient.HttpMethodBase processRedirectResponse
INFO: Redirect requested but followRedirects is disabled
org.apache.commons.httpclient.HttpException
at org.apache.webdav.lib.WebdavResource.propfindMethod(WebdavResource.java:3467)
at org.apache.webdav.lib.WebdavResource.propfindMethod(WebdavResource.java:3423)
at org.apache.webdav.lib.WebdavResource.setNamedProp(WebdavResource.java:967)
at org.apache.webdav.lib.WebdavResource.setBasicProperties(WebdavResource.java:912)
at org.apache.webdav.lib.WebdavResource.setProperties(WebdavResource.java:1894)
at org.apache.webdav.lib.WebdavResource.setHttpURL(WebdavResource.java:1301)
at org.apache.webdav.lib.WebdavResource.setHttpURL(WebdavResource.java:1320)
at org.apache.webdav.lib.WebdavResource.setHttpURL(WebdavResource.java:1408)
at org.apache.webdav.lib.WebdavResource.<init>(WebdavResource.java:290)
at slideclient.main(slideclient.java:19) -
Problem in runnign the sample code
2005-12-20 21:00:18 iesailaja [Reply | View]
org.apache.commons.httpclient.HttpException
at org.apache.webdav.lib.WebdavResource.propfindMethod(WebdavResource.java:3185)
at org.apache.webdav.lib.WebdavResource.propfindMethod(WebdavResource.java:3145)
at org.apache.webdav.lib.WebdavResource.setNamedProp(WebdavResource.java:879)
at org.apache.webdav.lib.WebdavResource.setBasicProperties(WebdavResource.java:824)
at org.apache.webdav.lib.WebdavResource.setProperties(WebdavResource.java:1746)
at org.apache.webdav.lib.WebdavResource.setHttpURL(WebdavResource.java:1156)
at org.apache.webdav.lib.WebdavResource.setHttpURL(WebdavResource.java:1175)
at org.apache.webdav.lib.WebdavResource.setHttpURL(WebdavResource.java:1261)
at org.apache.webdav.lib.WebdavResource.<init>(WebdavResource.java:274)
at com.sungard.sws.pi.dao.admin.FileServerDAO.listPath(FileServerDAO.java:1136)
at com.sungard.sws.pi.ejb.genAdminejbhelper.NotesTemplatesHelper.getNotesTemplates(NotesTemplatesHelper.java:51)
at com.sungard.sws.pi.ejb.workflow.WorkFlowEJBBean.getNotesTemplates(WorkFlowEJBBean.java:3937)
at com.sungard.sws.pi.ejb.workflow.EJSRemoteStatelessWorkFlowEJB_36f544ce.getNotesTemplates(EJSRemoteStatelessWorkFlowEJB_36f544ce.java:2163)
at com.sungard.sws.pi.ejb.workflow._WorkFlowEJBRemote_Stub.getNotesTemplates(_WorkFlowEJBRemote_Stub.java:4669)
at com.sungard.sws.pi.web.delegate.task.TaskBusinessDelegateImpl.getNoteTemplates(TaskBusinessDelegateImpl.java:366)
at com.sungard.sws.pi.web.task.actions.AddNoteAction.execute(AddNoteAction.java:46)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at com.sungard.sws.pi.web.framework.DefaultRequestProcessor.process(DefaultRequestProcessor.java:55)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:61)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:965)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:555)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:200)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:119)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:276)
at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:182)
at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:334)
at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:618)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:439)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:593) -
Problem in runnign the sample code
2005-05-25 03:30:09 Andrew Anderson [Reply | View]
I am not sure, as I do not have the code, but my best guess is that the httpclient is not setup to handle redirects, but the server is trying to redirect the request via an HTTP redirect. I think you will need to look into how to setup httpclient hto determine how to handle HTTP redirects.
Andrew
-
Traversing Directory Trees
2005-03-02 07:10:24 afsteed [Reply | View]
I'm having trouble using the slide webdav client to traverse a directory tree on the server.
My server is Apache 2.0.53 with webdav enabled, and the directory structure is:
/dav/
/dav/FolderA/
/dav/FolderB/
/dav/FolderB/FolderC/
/dav/, /dav/FolderA/, and /dav/FolderB/FolderC/ contain files.
If I create a WebdavResource to /dav/ and do either a list() or getChildResources() it lists only the files and not the subdirectories. However, it lists itself as a child if and only if there are subdirectories.
Example, if I remove FolderA and FolderB from /dav/, and do a list() or getChildResources() I get this:
/dav/file1.txt
/dav/file2.txt
But if /dav/ contains any subdirectories, I get this:
/dav/
/dav/file1.txt
/dav/file2.txt
Given a WebdavResource that is a collection, how do you get a list of the collections contained in it?
-
Corrections for A Simple Example code
2004-07-12 10:56:56 szpak [Reply | View]
I could not get the SlideTest code to compile as listed in this article. Here are the corrections I made to get it to compile:
- Instead of
import org.apache.util.httpURL;, I usedimport org.apache.commons.httpclient.HttpURL; - Instead of
hrl.setUserInfo("user", "pass");, I usedhrl.setUserinfo("user", "pass");
With these changes the code to get a file compiled and ran properly.
I could not get the code for uploading a file to work.wdr.putMethod(fn)returns a boolean. When getting a filegetMethod(fn)returns true, but when trying to upload a fileputMethod(fn)always returned false. After lots of hair pulling and searching FAQs and the Slide mailing list I was able to get it to work as follows:
String filename = "myLocalFilename";
File fn = new File(filename);
String path = wdr.getPath() + "/" + filename;
boolean rslt = wdr.putMethod(path,fn);
Hope this is helpful. Now on to more complex stuff...
- Mark - Instead of
-
Corrections for A Simple Example code
2005-06-06 07:36:05 MikeWilkinson [Reply | View]
Mark,
I cannot thank you enough!!!
I was having the same issue and you saved me an enormous amount of grief!
Thanks so much!
I hope some day maybe I can post something that will help you or others as you helped me.
You are the man!
MikeWilkinson
p.s. Thanks to the original article author as well even though there were a couple corrections that needed made for Slide 2.1 the article was helpful. -
Corrections for A Simple Example code
2008-02-21 16:48:11 WEBDAV [Reply | View]
Hi ,
I am new to WEBDAv,
HttpURL hrl = new HttpURL("http://apsw0442evs/exchange/user/Inbox/?Cmd=contents#");
hrl.setUserinfo("sroutr1","bubun123");
System.out.println(hrl.getUser());
wdr= new WebdavResource(hrl);
Currently i am using this code to get a connection to microsoft exchange server.But i need some assistance how to retrieve emails from Inbox folder.
Provide me the running code if you have....
Thanks
susanta
-
Corrections for A Simple Example code
2005-04-25 04:30:50 geetaChaurasia [Reply | View]
the sample code given does not work when used with in servlet. i am using WSAD to develop servlet and tomcat 5.0.28 as a server.
what could be the solution plz help.........
code snippet is
HttpURL hrl =new HttpURL("http://localhost:8080/webdav/");
hrl.setUserinfo("tomcat","tomcat");
System.out.print("inside test");
WebdavResource wdr = new WebdavResource(hrl);
System.out.print("inside test "+wdr.getPath());
the following error comes
[4/25/05 4:26:19:448 PDT] 246246c2 SystemOut O inside testinside test
[4/25/05 4:26:34:885 PDT] 246246c2 WebGroup E SRVE0026E: [Servlet Error]-[org.jdom.output.XMLOutputter: method <init>(Lorg/jdom/output/Format;)V not found]: java.lang.NoSuchMethodError: org.jdom.output.XMLOutputter: method <init>(Lorg/jdom/output/Format;)V not found
at org.apache.webdav.lib.BaseProperty.getPropertyAsString(BaseProperty.java:130)
at org.apache.webdav.lib.WebdavResource.processProperty(WebdavResource.java:4908)
at org.apache.webdav.lib.WebdavResource.setWebdavProperties(WebdavResource.java:1066)
at org.apache.webdav.lib.WebdavResource.setNamedProp(WebdavResource.java:968)
at org.apache.webdav.lib.WebdavResource.setBasicProperties(WebdavResource.java:912)
at org.apache.webdav.lib.WebdavResource.setProperties(WebdavResource.java:1894)
at org.apache.webdav.lib.WebdavResource.setHttpURL(WebdavResource.java:1301)
at org.apache.webdav.lib.WebdavResource.setHttpURL(WebdavResource.java:1320)
at org.apache.webdav.lib.WebdavResource.setHttpURL(WebdavResource.java:1408)
at org.apache.webdav.lib.WebdavResource.<init>(WebdavResource.java:290)
at test.FileUploadServlet.doPost(FileUploadServlet.java:122)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:258)
at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:872)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:491)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:173)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:79)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:199)
at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:182)
at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:331)
at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:432)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:343)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:592)
-
Corrections for A Simple Example code
2004-07-12 13:29:40 Andrew Anderson [Reply | View]
All the examples in the article worked when the article was published.
Could it be you were using the newer version of Slide that was released in June 2004 ?
Andrew -
Corrections for A Simple Example code
2005-04-25 07:12:45 geetaChaurasia [Reply | View]
yes i have latest code downloaded from apache site.i am using jakarta-slide-webdavclient-src-2.1 for this purpose. yes i made some some corrections while using the code for eg: replaceAll method . i have written my own code for this.
when used same corrected code with in java application the code works fine , how it is possible ?? i am using same code for both servlet and java application......
-
Running Example with Microsoft Exchange Server
2004-01-15 17:01:08 reiners [Reply | View]
Has anyone got the example working with Microsoft Exchange Server? I get the following error when I try:
org.apache.commons.httpclient.HttpException: Bad Set-Cookie header: sessionid=e9d81ac0-2f67-4572-9018-3ebb2240c1fe,0x0; path=/exchange/db2admin
Missing value for cookie '0x0'
at org.apache.commons.httpclient.Cookie.parse(Cookie.java:381)
at org.apache.commons.httpclient.HttpClient.parseHeaders(HttpClient.java:1170)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:492)
at org.apache.webdav.lib.WebdavResource.getMethod(WebdavResource.java:2113)
at org.apache.webdav.lib.WebdavResource.getMethod(WebdavResource.java:2092)
at SlideTest.main(SlideTest.java:22)
-
Running Example with Microsoft Exchange Server
2004-01-17 15:48:03 Andrew Anderson [Reply | View]
It looks like Microsoft Exchange Server is trying to set a cookie on your machine and is not succesfully doing it.
Check out the documentation for Apache's HttpClient Cookies at: http://jakarta.apache.org/commons/httpclient/apidocs/org/apache/commons/httpclient/cookie/package-summary.html
It might shed some light on your problem.
Andrew




