Results 1 to 9 of 9

Thread: [SOLVED] SOAP API from Java

  1. #1
    Join Date
    Sep 2007
    Location
    Argentina
    Posts
    10
    Rep Power
    8

    Default [SOLVED] SOAP API from Java

    I want to create accounts in zimbra from a java aplication. Y followed the wiki on ZClient - ZimbraWiki and I couldnt get auth token.
    I did something like this (on Ubuntu 7.04, Zimbra 4.5, Eclipse 3.2):

    SoapHttpTransport trans = null;
    try {
    trans = new SoapHttpTransport("https://www.technicaldetails.org" + ZimbraServlet.USER_SERVICE_URI);
    Element request = Element.XMLElement.mFactory.createElement(AccountS ervice.AUTH_REQUEST);
    request.addAttribute(AccountService.E_ACCOUNT, "userdoesntexist@technicaldetails.org", Element.DISP_CONTENT);
    request.addAttribute(AccountService.E_PASSWORD, "notapassword", Element.DISP_CONTENT);
    Element response = trans.invoke(request);
    }
    catch (Exception E)
    e.printStackTrace();
    }

    But I had problemas with ssl. First throws javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException, then I did something like:
    jturner@teacup:~$ openssl s_client -connect imap.atlassian.com:imaps
    to get the certificate and
    jturner@teacup:~$ keytool -import -alias mail.yourcompany.com -keystore /etc/java/keystore -file imapd.pem
    And runs the applecation with -Djavax.net.ssl.trustStore=/etc/java/keystore
    But throws java.net.SocketException: Default SSL context init failed: Invalid keystore format

    Anybody can help me please??

  2. #2
    Join Date
    Nov 2005
    Posts
    477
    Rep Power
    10

    Default

    Quote Originally Posted by liriarte View Post
    I want to create accounts in zimbra from a java aplication. Y followed the wiki on ZClient - ZimbraWiki and I couldnt get auth token.
    I did something like this (on Ubuntu 7.04, Zimbra 4.5, Eclipse 3.2):

    SoapHttpTransport trans = null;
    try {
    trans = new SoapHttpTransport("https://www.technicaldetails.org" + ZimbraServlet.USER_SERVICE_URI);
    Element request = Element.XMLElement.mFactory.createElement(AccountS ervice.AUTH_REQUEST);
    request.addAttribute(AccountService.E_ACCOUNT, "userdoesntexist@technicaldetails.org", Element.DISP_CONTENT);
    request.addAttribute(AccountService.E_PASSWORD, "notapassword", Element.DISP_CONTENT);
    Element response = trans.invoke(request);
    }
    catch (Exception E)
    e.printStackTrace();
    }

    But I had problemas with ssl. First throws javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException, then I did something like:
    jturner@teacup:~$ openssl s_client -connect imap.atlassian.com:imaps
    to get the certificate and
    jturner@teacup:~$ keytool -import -alias mail.yourcompany.com -keystore /etc/java/keystore -file imapd.pem
    And runs the applecation with -Djavax.net.ssl.trustStore=/etc/java/keystore
    But throws java.net.SocketException: Default SSL context init failed: Invalid keystore format

    Anybody can help me please??
    what does /etc/java/keystore look like? (don't copy and paste the key, but is it ascii, binrary, etc? Does it contain error messages?

  3. #3
    Join Date
    Sep 2007
    Location
    Argentina
    Posts
    10
    Rep Power
    8

    Default

    I put the response of openssl command in a file imapd.pem, it looks like a certificate with
    -----BEGIN CERTIFICATE-----
    **
    -----END CERTIFICATE-----

    The I try to import that certificate with keytool and try to call zimbra from my eclipse with this keytore. Is it right?
    --

  4. #4
    Join Date
    Aug 2005
    Posts
    1,433
    Rep Power
    12

    Default

    Quote Originally Posted by liriarte View Post
    I want to create accounts in zimbra from a java aplication.
    Have you considered using the SoapProvisioning.java class? It wraps all the account/cos/domain/etc. provisioning requests in a Java interface.
    Bugzilla - Wiki - Downloads - Before posting... Search!

  5. #5
    Join Date
    Sep 2007
    Location
    Argentina
    Posts
    10
    Rep Power
    8

    Default

    Quote Originally Posted by dkarp View Post
    Have you considered using the SoapProvisioning.java class? It wraps all the account/cos/domain/etc. provisioning requests in a Java interface.
    Yes I tried that and also I tried something like
    Zimbra.toolSetup();
    String serverURL = "http://tsavo4:7071/zimbra";
    LmcPingRequest pr = new LmcPingRequest();
    try {
    LmcPingResponse pResp = (LmcPingResponse) pr.invoke(serverURL);
    }

    But nothing, the problem is with ssl and certificates.

  6. #6
    Join Date
    Sep 2007
    Location
    Argentina
    Posts
    10
    Rep Power
    8

    Default com.zimbra.soap.SoapParseException: unable to parse response:

    Quote Originally Posted by liriarte View Post
    Yes I tried that and also I tried something like
    Zimbra.toolSetup();
    String serverURL = "http://tsavo4:7071/zimbra";
    LmcPingRequest pr = new LmcPingRequest();
    try {
    LmcPingResponse pResp = (LmcPingResponse) pr.invoke(serverURL);
    }

    But nothing, the problem is with ssl and certificates.
    I can fixed the ssl problem. Know I get this:
    com.zimbra.soap.SoapParseException: unable to parse response: <html><head><title>Apache Tomcat/5.5.15 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;

    ?¿

  7. #7
    Join Date
    Aug 2005
    Posts
    1,433
    Rep Power
    12

    Default

    Send the request to http://tsavo4:7071/service/admin/soap instead of http://tsavo4:7071/zimbra. And seriously, please consider using the SoapProvisioning.java class.
    Bugzilla - Wiki - Downloads - Before posting... Search!

  8. #8
    Join Date
    Sep 2007
    Location
    Argentina
    Posts
    10
    Rep Power
    8

    Default

    Quote Originally Posted by dkarp View Post
    Send the request to http://tsavo4:7071/service/admin/soap instead of http://tsavo4:7071/zimbra. And seriously, please consider using the SoapProvisioning.java class.
    The url is not the problem, with that change nothing happens. I will use SoapProvisioning but I have the same error

  9. #9
    Join Date
    Aug 2005
    Posts
    1,433
    Rep Power
    12

    Default

    Right! Since you're going to the admin interface, you must use https.
    Bugzilla - Wiki - Downloads - Before posting... Search!

Similar Threads

  1. SOAP API docs
    By olliemaitland in forum Migration
    Replies: 2
    Last Post: 05-18-2010, 06:02 PM
  2. Replies: 3
    Last Post: 04-28-2010, 10:46 AM
  3. SOAP API / errors more specific than 500?
    By rachale in forum Developers
    Replies: 3
    Last Post: 06-29-2007, 03:53 PM
  4. How to consume zimbra SOAP API in my java application
    By Hemant Shrivastava in forum Developers
    Replies: 34
    Last Post: 12-24-2006, 01:24 AM
  5. Replies: 0
    Last Post: 12-04-2006, 09:48 PM

Posting Permissions

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