我正在尝试使用iCal4j从我的zimbra帐户下载vcard列表。
我试过这段代码。 它正确地获取集合,但它不下载任何vCard。
如果我调试getCollections方法,我可以看到HTTP / 1.1 400 Bad Request错误。
有人可以帮忙吗?
此致
斯特凡诺
CardDavStore kerioStore = new CardDavStore("//MacTI/MKS2Exchange", new URL("https://xxx.xxx.xxx"), PathResolver.ZIMBRA);
kerioStore.connect("xxx.xxx@xxx.xxx", "supersecret".toCharArray());
for (CardDavCollection collection: kerioStore.getCollections()) {
for (VCard card: collection.getComponents()) {
System.out.println(card.toString());
}
}
这是HTTP请求跟踪:
DEBUG [main] HttpMethodBase.shouldCloseConnection(1024) | Resorting to protocol version default close connection policy
DEBUG [main] HttpMethodBase.shouldCloseConnection(1028) | Should NOT close connection, using HTTP/1.1
DEBUG [main] HttpConnection.releaseConnection(1178) | Releasing connection back to connection manager.
DEBUG [main] header.wire(70) | >> "REPORT /dav/<myemailaccount>/TestCardDav/ HTTP/1.1[\r][\n]"
DEBUG [main] HttpMethodBase.addHostRequestHeader(1352) | Adding Host request header
DEBUG [main] header.wire(70) | >> "Depth: 1[\r][\n]"
DEBUG [main] header.wire(70) | >> "User-Agent: Jakarta Commons-HttpClient/3.1[\r][\n]"
DEBUG [main] header.wire(70) | >> "Host: xxx.xxx.xxx[\r][\n]"
DEBUG [main] header.wire(70) | >> "Content-Length: 199[\r][\n]"
DEBUG [main] header.wire(70) | >> "Content-Type: text/xml; charset=UTF-8[\r][\n]"
DEBUG [main] header.wire(70) | >> "[\r][\n]"
DEBUG [main] content.wire(84) | >> "<?xml version="1.0" encoding="UTF-8" standalone="no"?><C:addressbook-query xmlns:C="urn:ietf:params:xml:ns:carddav"><D:prop xmlns:D="DAV:"><C:address-data/><D:getetag/></D:prop></C:addressbook-query>"
DEBUG [main] EntityEnclosingMethod.writeRequestBody(508) | Request body sent
DEBUG [main] header.wire(70) | << "HTTP/1.1 401 must authenticate[\r][\n]"
DEBUG [main] header.wire(70) | << "HTTP/1.1 401 must authenticate[\r][\n]"
DEBUG [main] header.wire(70) | << "Date: Wed, 04 Dec 2013 22:16:48 GMT[\r][\n]"
DEBUG [main] header.wire(70) | << "WWW-Authenticate: BASIC realm="Zimbra"[\r][\n]"
DEBUG [main] header.wire(70) | << "Content-Length: 0[\r][\n]"
DEBUG [main] header.wire(70) | << "[\r][\n]"
DEBUG [main] HttpMethodDirector.isAuthenticationNeeded(843) | Authorization required
DEBUG [main] AuthChallengeProcessor.selectAuthScheme(90) | Supported authentication schemes in the order of preference: [Digest, Basic]
DEBUG [main] AuthChallengeProcessor.selectAuthScheme(111) | Challenge for Digest authentication scheme not available
INFO [main] AuthChallengeProcessor.selectAuthScheme(101) | Basic authentication scheme selected
DEBUG [main] AuthChallengeProcessor.processChallenge(155) | Using authentication scheme: basic
DEBUG [main] AuthChallengeProcessor.processChallenge(163) | Authorization challenge processed
DEBUG [main] HttpMethodDirector.processWWWAuthChallenge(714) | Authentication scope: BASIC 'Zimbra'@mail.zcsmail.eu:443
DEBUG [main] HttpMethodDirector.executeMethod(194) | Retry authentication
DEBUG [main] HttpMethodBase.shouldCloseConnection(1024) | Resorting to protocol version default close connection policy
DEBUG [main] HttpMethodBase.shouldCloseConnection(1028) | Should NOT close connection, using HTTP/1.1
DEBUG [main] HttpConnection.releaseConnection(1176) | Connection is locked. Call to releaseConnection() ignored.
DEBUG [main] HttpMethodDirector.authenticateHost(278) | Authenticating with BASIC 'Zimbra'@xxx.xxx.xxx:443
DEBUG [main] HttpMethodParams.getCredentialCharset(384) | Credential charset not configured, using HTTP element charset
DEBUG [main] header.wire(70) | >> "REPORT /dav/<myemailaccount>/TestCardDav/ HTTP/1.1[\r][\n]"
DEBUG [main] HttpMethodBase.addHostRequestHeader(1352) | Adding Host request header
DEBUG [main] header.wire(70) | >> "Depth: 1[\r][\n]"
DEBUG [main] header.wire(70) | >> "User-Agent: Jakarta Commons-HttpClient/3.1[\r][\n]"
DEBUG [main] header.wire(70) | >> "Content-Length: 199[\r][\n]"
DEBUG [main] header.wire(70) | >> "Content-Type: text/xml; charset=UTF-8[\r][\n]"
DEBUG [main] header.wire(70) | >> "Authorization: Basic xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx==[\r][\n]"
DEBUG [main] header.wire(70) | >> "Host: xxx.xxx.xxx[\r][\n]"
DEBUG [main] header.wire(70) | >> "[\r][\n]"
DEBUG [main] content.wire(84) | >> "<?xml version="1.0" encoding="UTF-8" standalone="no"?><C:addressbook-query xmlns:C="urn:ietf:params:xml:ns:carddav"><D:prop xmlns:D="DAV:"><C:address-data/><D:getetag/></D:prop></C:addressbook-query>"
DEBUG [main] EntityEnclosingMethod.writeRequestBody(508) | Request body sent
DEBUG [main] header.wire(70) | << "HTTP/1.1 400 Bad Request[\r][\n]"
DEBUG [main] header.wire(70) | << "HTTP/1.1 400 Bad Request[\r][\n]"
DEBUG [main] header.wire(70) | << "Date: Wed, 04 Dec 2013 22:16:49 GMT[\r][\n]"
DEBUG [main] header.wire(70) | << "Content-Length: 0[\r][\n]"
DEBUG [main] header.wire(70) | << "[\r][\n]"