如何使用 HttpClient 进行 WebDav 调用?
具体来说,我想通过 HttpClient
调用 MKCOL
通过 Sling REST API 为 Apache Jackrabbit 创建文件夹。
我已经尝试过
BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("MKCOL", restUrl);
但到目前为止还没有骰子的变体。我猜这比我做的要容易。
我还看到有 MkColMethod
之类的东西
MkColMethod mkColMethod = new MkColMethod(restUrl);
但我不知道如何利用它。我认为它可能适用于 HttpClient 的早期版本。我用的是4.x
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最好是查看 Sling 集成测试,它使用 Sling 的 RESTful API 来创建内容。
"旧" SlingIntegrationTestClient 类 用于测试 Sling 本身,使用
httpclient 3.x
创建内容。 此处的测试使用它,所以你可以在那里找到例子。“新”SlingClient 类 旨在对其进行更清晰、更简单的重新实现,由 http://sling.apache.org/site/sling-testing-tools.html< /a> .它使用
httpclient 4.x
,其 API 略有不同。SlingClient.mkdir 和 mkdirs 方法确实使用 MKCOL 方法。
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 是一个易于使用的 Java webdav 客户端
Sardine is an easy to use webdav client for Java