问题描述
我具体想通过 HttpClient
通过Sling REST API为Apache Jackrabbit创建一个文件夹.
Specifically I want to call MKCOL
through HttpClient
to create a folder for Apache Jackrabbit through the Sling REST API.
我尝试了
BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("MKCOL", restUrl);
但到目前为止,还没有骰子.我想这要比我做的难.
But no dice so far. I'm guessing this is less difficult than I'm making it.
我还看到有 MkColMethod
之类的东西
I also see there is MkColMethod
for something like
MkColMethod mkColMethod = new MkColMethod(restUrl);
但是我不知道该如何利用.我认为它可能与HttpClient的早期版本一起使用.我正在使用4.x
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
推荐答案
最好是研究Sling集成测试,该测试使用Sling的RESTful API创建内容.
Best is to look at the Sling integration tests, which use Sling's RESTful APIs to create content.
"旧的"SlingIntegrationTestClient类用于测试Sling本身,并使用 httpclient 3.x
创建内容.在此处找到的测试中使用它,因此您可以在此处找到示例.
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.
"新的"SlingClient类旨在对其进行更干净,更简单的重新实现,由 http://sling.apache.org/site/sling-testing-tools.html .它使用 httpclient 4.x
,该API的API稍有不同.
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.
SlingClient.mkdir和mkdirs方法确实使用MKCOL方法.
The SlingClient.mkdir and mkdirs methods do use the MKCOL method.
这篇关于如何使用HttpClient进行WebDav调用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!