开发者

How do I make a WebDav call using HttpClient?

开发者 https://www.devze.com 2023-03-06 19:58 出处:网络
Specifically I want to call MKCOL through HttpClient to create a folder for Apache Jackrabbit through the Sling REST API.

Specifically I want to call MKCOL through HttpClient to create a folder for Apache Jackrabbit through the Sling REST API.

I've tried variants of

BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("MKCOL", restUrl);
开发者_如何转开发

But no dice so far. I'm guessing this is less difficult than I'm making it.

I also see there is MkColMethod for something like

MkColMethod mkColMethod = new MkColMethod(restUrl);

But I don't know how to utilize this. I think it may have worked with a previous version of HttpClient. I'm using 4.x


Best is to look at the Sling integration tests, which use Sling's RESTful APIs to create content.

The "old" SlingIntegrationTestClient class is used to test Sling itself and uses httpclient 3.x to create content. It is used by the tests found here, so you can find examples there.

The "new" SlingClient class is meant to be a cleaner and simpler re-implementation of that, used by the Sling testing tools described at http://sling.apache.org/site/sling-testing-tools.html . It uses httpclient 4.x which has a slightly different API.

The SlingClient.mkdir and mkdirs methods do use the MKCOL method.


Sardine is an easy to use webdav client for Java

0

精彩评论

暂无评论...
验证码 换一张
取 消