I make it quick:
Zimbra API always responses in JSON. I need to process the response in my Java app (not JavaScript).
Do you know any Java class that can parse JSON?
-or-
Can Zimbra response in any other format?
I make it quick:
Zimbra API always responses in JSON. I need to process the response in my Java app (not JavaScript).
Do you know any Java class that can parse JSON?
-or-
Can Zimbra response in any other format?
Yes , you can process JSON in JAVA:
http://www.json.org/javadoc/org/json/JSONObject.html
Zimbra by default responds with the same format your request is in. So if your resuest is SOAP 1.2, Zimbra responds in SOAP 1.2. If your request is JSON, Zimbra sends back JSON.
You can override this (and the Web client does) by adding a <format> element to the <context> element in the SOAP header. But if you send XML and leave off the special <format> tag, you'll get XML back.
Here is my request:
And here Zimbra's response:Code:POST /service/admin/soap/ HTTP/1.1
Content-Type: application/soap+xml; charset=utf-8
User-Agent: Test application
Host: 192.168.0.180:7071
Content-Length: 342
Connection: Keep-Alive
Cache-Control: no-cache
Pragma: no-cache
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
<soap:Header>
<context xmlns="urn:zimbra">
<nosession/>
<format type="js"/>
</context>
</soap:Header>
<soap:Body>
<AuthRequest xmlns="urn:zimbraAccount">
<account by="name">amir.far@MYDOMAIN.com</account>
<password>1234</password>
</AuthRequest>
</soap:Body>
</soap:Envelope>
As you see my request is in XML but the response from is JSON !Code:HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-Type: text/javascript;charset=utf-8
Content-Length: 275
Date: Tue, 19 Dec 2006 18:38:36 GMT
{Body:{AuthResponse:{lifetime:172800000,authToken:"0_9175f262ba2f814f542486fc4d39f4c2e771fb89_69643d33363a64386463643230662d613239622d346131352d613662622d6232626437363230376237343b6578703d31333a313136363732363331363734343b",_jsns:"urn:zimbraAccount"}},_jsns:"urn:zimbraSoap"}
Im going to try <format>
Do you see that <format type="js"/> line in your request? That explicitly requests a JSON response. Take it out and you'll get XML back.
Im sorry, you are right, I should have copy and pasted the request from the webmail client's debug window.
I can not find documentation for the <format> tag in SOAP.txt
http://zimbra.svn.sourceforge.net/vi...88&view=markup
What are my options other than "js"?
If I remove <format type="js"/> then Zimbra does not response! (connection time out). type="xml" has the same effect.
sound like a content-length bug. are you reducing the amount of data you are sending, but not decreasing the content-length you are sending?
If so, the server waits until you send it the number of bytes indicated in the content-length header. If your content-length is greater than the amount of data you actually send, the symptom is a timeout.
Leaving the <format> element out should not cause the Zimbra server to hang. In fact, much our internal SOAP testing is done without setting <format>.
Can you post the request that's hanging on the server? Because that's really, really weird.
Or, what Sam said. I'd go with that option first.
I am sending the exact same request without <format type="js">. which is 19 characters.
My code calculates the length of the soap body right before posting it and puts it in the header. It calculates the lenght starting from begining of "<soap:Envelope"...to the end of..."</soap:Envelope>"
Here is my request with <format type="js"/> which works.
And here is the request without format tag, which does not work, (time out):Code:POST /service/admin/soap/ HTTP/1.1
Content-Type: application/soap+xml; charset=utf-8
User-Agent: Test application
Host: 192.168.0.180:7071
Content-Length: 332
Connection: Keep-Alive
Cache-Control: no-cache
Pragma: no-cache
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"><soap:Header><context xmlns="urn:zimbra"><nosession/><format type="js"/></context></soap:Header><soap:Body><AuthRequest xmlns="urn:zimbraAccount"><account by="name">amir.far@xxxxxxxxx.com</account><password>1234</password></AuthRequest></soap:Body></soap:Envelope>
Note that the content length is 19 characters shorter.Code:POST /service/admin/soap/ HTTP/1.1
Content-Type: application/soap+xml; charset=utf-8
User-Agent: Test application
Host: 192.168.0.180:7071
Content-Length: 313
Connection: Keep-Alive
Cache-Control: no-cache
Pragma: no-cache
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"><soap:Header><context xmlns="urn:zimbra"><nosession/></context></soap:Header><soap:Body><AuthRequest xmlns="urn:zimbraAccount"><account by="name">amir.far@xxxxxxxxx.com</account><password>1234</password></AuthRequest></soap:Body></soap:Envelope>
By the way, I have replaced my 9 characters long domain name with 9 "x"s.
7071 is the admin port. Are you trying to do an admin auth? What happens when you send the request to port 7070?