我想使用 REST 请求获取我所有的 zimbra 日历的名称。怎么做 ?谢谢
问问题
1635 次
2 回答
1
这不是 REST,甚至不是 Zimbra 的 SOAP API,但它是一个解决方案:
URL url = new URL(SOAPUrl);
URLConnection connection = url.openConnection();
HttpURLConnection httpConn = (HttpURLConnection) connection;
String postContent = "<soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\">"+
"<soap:Header>" +
"<context xmlns=\"urn:zimbra\">" +
"<format type=\"js\"/>" +
"<authToken>" + authToken + "</authToken>" +
"</context>" +
"</soap:Header>" +
"<soap:Body>" +
"<GetFolderRequest xmlns=\"urn:zimbraMail\" />" +
"</soap:Body>" +
"</soap:Envelope>";
// insert your SOAP XML!!!
byte[] b = postContent.getBytes();
// Set the appropriate HTTP parameters.
httpConn.setRequestProperty( "Content-Length", String.valueOf( b.length ) );
httpConn.setRequestProperty("Content-Type","application/soap+xml; charset=utf-8");
httpConn.setRequestMethod( "POST" );
httpConn.setDoOutput(true);
httpConn.setDoInput(true);
// Everything's set up; send the XML that was read in to b.
OutputStream out = httpConn.getOutputStream();
out.write( b );
out.close();
// Read the response and write it to standard out.
InputStreamReader isr = new InputStreamReader(httpConn.getInputStream());
BufferedReader in = new BufferedReader(isr);
// read & do something with input stream...
String s = null;
String soapResponse = "";
while((s=in.readLine()) != null){
soapResponse += s;
}
System.out.println(soapResponse);
当您解析结果时,获取与您想要的文件夹相对应的文件夹(约会...)
于 2011-06-22T15:35:02.837 回答
0
我不认为你可以用 REST 做到这一点。但是您可以使用 SOAP 来做到这一点。检查以下网址。
http://mmrblogger.blogspot.in/2013/04/how-to-get-all-calendar-names-for.html
于 2013-04-19T09:00:50.597 回答