RESTリクエストを使用してすべてのzimbraカレンダーの名前を取得したい。どうやってするの ?Thnx
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 を使用してそれを行うことができます。以下の URL を確認してください。
http://mmrblogger.blogspot.in/2013/04/how-to-get-all-calendar-names-for.html
于 2013-04-19T09:00:50.597 に答える