Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 25

Thread: API and JSON responses, How to read it in Java not JavaScript

  1. #11
    seeker is offline Intermediate Member
    Join Date
    Nov 2006
    Posts
    19
    Rep Power
    8

    Question

    Server refuses connection on port 7070, did you mean 8080?

    At this point I just need to create an application that can talk to Zimbra as an admin or client, so it doesnt really matter witch one, I found them very similar.

    Any way here is the deal, I swiched to client from admin and here is my request:

    Code:
    POST /service/soap/ HTTP/1.1
    Content-Type: application/soap+xml; charset=utf-8
    User-Agent: Test application
    Host: 192.168.0.180:8080
    Content-Length: 366
    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>1234111</password>
    			
    		</AuthRequest>
    	</soap:Body>
    </soap:Envelope>
    Zimbra responses nicely in XML, and everything seems good. BUT, this happens only if my authentication fails! (On the above request I am sending an incorrect password).

    If I provide the correct password without the <format> tag, connection times out !

    If I provide the correct password with <format type="js"/>, zimbra responses nicely.

    I need xml response.
    Any idea?

  2. #12
    dkarp is offline Zimbra Employee
    Join Date
    Aug 2005
    Posts
    1,433
    Rep Power
    12

    Default Strip out all the extra headers and see

    You've got a wacky, wacky situation here, so it's time to prune off any differences from what everyone else is sending.

    Try removing all the non-required HTTP headers from your request. I mean all of them -- figure out what the minimum legal HTTP request is (I think it's just the Host header) and send that. In particular, kill the Content-Length, User-Agent, and Connection headers if possible.

    If that works, add your headers back one by one until it breaks. Then we can figure out if its our bug (probable) or yours.
    Bugzilla - Wiki - Downloads - Before posting... Search!

  3. #13
    seeker is offline Intermediate Member
    Join Date
    Nov 2006
    Posts
    19
    Rep Power
    8

    Default

    Here is the least HTTP headers that Zimbra accepts.

    Code:
    POST /service/soap/ HTTP/1.1
    Host: 192.168.0.180:8080
    Content-Length: 363
    
    <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>
    If I make the content-length any shorter, Zimbra will complain about an error on XML body. HTTP/1.1 500 Internal Server Error Server "...<soap:Reason><soap:Text>parse error: Error on line 15 of document : XML document structures must start and end within the same entity. Nested exception: XML document structures must start and end within the same entity.</soap:Text></soap:Reason>..." which means Zimbra reads the XML body exactly as dictated by content-length. Oh by the way this error response is in XML !!!

    If I make the content-length any longer, Zimbra waits to receive more bytes and connection times out , that happens even if I put <format type="js"/>.

    So I think the content-length is not the issue.

    My conclusion:
    Zimbra does not respond in XML (connection times out) if response should be a success (HTTP 200), but it does respond in XML if response is a failure (HTTP 500) such as AUTH_FAILED or PARSE_ERROR.

    Another point I noticed is that, Zimbra's HTTP 500 responds are always in XML if content-length is not right even if I put <format type="js"/> in the request body. Incorrect Content-length produces a PARSE_ERROR.

    Has anyone ever received a successful response (HTTP 200) in XML (SOAP)?

  4. #14
    dkarp is offline Zimbra Employee
    Join Date
    Aug 2005
    Posts
    1,433
    Rep Power
    12

    Default You're somehow the only one with this issue

    Quote Originally Posted by seeker View Post
    Has anyone ever received a successful response (HTTP 200) in XML (SOAP)?
    Like I said, almost all our API tests send XML and receive XML. Pretty much all third parties using the SOAP API both send and receive XML. Believe it or not, you are the only person who has had issues with this.

    So if you leave off the Content-Length header entirely, it doesn't work?

    And when things don't work, there are no errors in the logfiles?

    (PS - Which version of ZCS are you running?)
    Bugzilla - Wiki - Downloads - Before posting... Search!

  5. #15
    seeker is offline Intermediate Member
    Join Date
    Nov 2006
    Posts
    19
    Rep Power
    8

    Default

    Im using 4.0.3.GA_406.FC5_20061016122824 FC5 FOSS edition

    Please send me the name and location of the logs I should watch.
    /opt/zimbra/zimbra.log is not affected , even with a successful login.
    /opt/zimbra/audit.log is also not affected!


    If I take the content-length off, Zimbra will not response with error:
    HTTP/1.1 500...
    ...<soap:Text>system failure:java.lang.ArrayIndexOutOfBoundsExecption: 0</soap:Text></soap:Reason>...

  6. #16
    dkarp is offline Zimbra Employee
    Join Date
    Aug 2005
    Posts
    1,433
    Rep Power
    12

    Default Logfiles

    /opt/zimbra/log/zimbra.log is the right logfile to watch.

    And since I'm stumped by your issue, let's bring out the big guns. Send the request to the server that makes it "hang", then while it's hanging send the tomcat process a kill -3. The hung thread should be prominent in the stack trace that will appear in /opt/zimbra/log/zimbra.log.
    Bugzilla - Wiki - Downloads - Before posting... Search!

  7. #17
    seeker is offline Intermediate Member
    Join Date
    Nov 2006
    Posts
    19
    Rep Power
    8

    Default

    I send the request with no <format type="js"/> from my client machine and wait for response from zimbra, then before connection times out on the client I quickly go to the zimbra box and do this :

    #ps -A | grep java
    3524 ? 00:00:06 java
    #kill -3 3524

    and then I open /opt/zimbra/log/zimbra.log , nothing is there! no new entry.

    But accidentally I discovered that if I kill the tomcat process (with no -3) while client is waiting for response, I get several lines on zimbra.log that show it is restarting and then on client I GET HTTP 200 SOAP RESPONSE!!!! but thats just once, after that, its the same story (connection times out) unless I kill tomcat again.

    P.S. I looked for /opt/zimbra/tomcat/logs/stacktrace.xxxx after running kill -3 xxxx, I could not find any.

    This may be useful:
    When I send the request from the client machine which times out, I get a new entry on /opt/zimbra/tomcat/logs/access_log.2006-12-23 :
    Code:
    192.168.0.113 - - [23/Dec/2006:10:42:46 -0500] "POST /service/soap/ HTTP/1.1" 200 386 "-" "-"
    thats the IP address of my client machine, it shows that zimbra produces the HTTP 200 response, but I dont get it on client side! , this is not a networking issue since I do get response if I ask for JSON response.

  8. #18
    dkarp is offline Zimbra Employee
    Join Date
    Aug 2005
    Posts
    1,433
    Rep Power
    12

    Default kill -3 tomcat

    tomcat is the server process. kill -3 <tomcat pid> and post the resulting stacktrace found in /opt/zimbra/log/zimbra.log.
    Bugzilla - Wiki - Downloads - Before posting... Search!

  9. #19
    seeker is offline Intermediate Member
    Join Date
    Nov 2006
    Posts
    19
    Rep Power
    8

    Default

    I did that as you asked me before, see my previous post, and I got nothing in the zimbra.log file.

    is that the right wait to get the tomcat process id ?

  10. #20
    dkarp is offline Zimbra Employee
    Join Date
    Aug 2005
    Posts
    1,433
    Rep Power
    12

    Default Actually, wrong logfile

    The correct logfile for the tomcat stacktrace is /opt/zimbra/tomcat/logs/catalina.out. Sorry for the confusion.

    You're getting the tomcat pid correctly, as far as I can tell.
    Bugzilla - Wiki - Downloads - Before posting... Search!

Page 2 of 3 FirstFirst 123 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •