Results 1 to 9 of 9

Thread: Zimbra Calendar Client using SOAP or zclient

  1. #1
    Join Date
    Mar 2011
    Location
    Lansing, MI
    Posts
    17
    Rep Power
    4

    Default Zimbra Calendar Client using SOAP or zclient

    This is generic request, how to get Zimbra client started in Java v1.6.

    We are running Zimbra 6.0, and need to write code to check/modify users' calendars to find for free time and setup meetings.

    Looking to avoid writing SOAP, I am checking zclient. I can login as admin, but am overloaded with # of methods available in SoapProvisioning, Account, etc.

    Is zclient a good tool for doing this, or should I write SOAP?

    If zclient is good, please let me know how to get person's calendar free times, and any notes on how to create/delete meetings as well.


    Thank you for your attention,
    Ray

  2. #2
    Join Date
    Mar 2011
    Location
    Lansing, MI
    Posts
    17
    Rep Power
    4

    Default

    I have seen examples for using ZMailbox and other items, confusing me further. It looks like I am on a wild goose chase.

    We need to write Java client to support an application used by our University so students can sign up to meet their advisers.

    Any response on directions to consider would be greatly appreciated, so I can stop chasing the goose.

    Please help in any way you can.

  3. #3
    Join Date
    Mar 2012
    Posts
    7
    Rep Power
    3

    Default

    One year later , I have the same dilemma... ZMailbox or SOAP?
    Which path did you finally choose?

  4. #4
    Join Date
    Mar 2011
    Location
    Lansing, MI
    Posts
    17
    Rep Power
    4

    Default

    SOAP -> it works fine, once you get used to the structure (like envelope specifying xmlns for "urn:zimbra", "urn:zimbraAccount", etc.)

  5. #5
    Join Date
    Mar 2012
    Posts
    7
    Rep Power
    3

    Default

    Would it be possible for you to post a sample java code calling one of these SOAP web services?
    Thanks.

  6. #6
    Join Date
    Mar 2011
    Location
    Lansing, MI
    Posts
    17
    Rep Power
    4

    Default Sample code

    I do not know if I can give you a copy of our code.

    Here is example code using sockets; we wrote our own wrappers for this, instead of using a framework.

    REQUEST: replace [hostName], [port], and [soapRequest], and this should be able to run a request.

    Code:
    import java.io.BufferedWriter;
    import java.io.OutputStreamWriter;
    import java.net.InetAddress;
    import java.net.Socket;
    import javax.net.ssl.SSLSocket;
    import javax.net.ssl.SSLSocketFactory;
    
    Socket socket = null;
    if (ssl) {
    	// Using SSL
    	SSLSocketFactory factory = (SSLSocketFactory)SSLSocketFactory.getDefault();
    	socket = (SSLSocket)
    		factory.createSocket(InetAddress.getByName([hostName]), [port]);
    } else {
    	// Simple Socket
    	socket = new Socket(InetAddress.getByName([hostName]), [port]);
    }
    socket.setKeepAlive(true);
    Writer writer = new BufferedWriter(
    		new OutputStreamWriter(socket.getOutputStream(), "UTF-8"));
    writer.write([soapRequest]);
    writer.flush();
    RESPONSE: use the reader to get the header and contents.
    Code:
    import java.io.BufferedReader;
    import java.io.InputStreamReader;
    
    BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream());
    Read entire header, finding line "Content-Length: #[#[#]]"

    Get that length, as that is critical to knowing when to stop reading the response

    Once you got the entire header, you need to read the contents for that exact # of characters. Note that I found there may be a couple of empty lines before the contents, and those do not counted for, so you may end up missing the last couple characters in the response.

    If you need example SOAP, check out the following. Note that also includes Java code, may be helpful, but we chose to not use that.

    http://www.zimbra.com/forums/develop..._document.html

    Good Luck.

  7. #7
    Join Date
    Mar 2012
    Posts
    7
    Rep Power
    3

    Default

    Your help is very much appreciated. Thank you.

    I've made some progress... I'm now able to authenticate using the admin account.

    Code:
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
        xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
        xmlns:zaccount="urn:zimbraAccount"
        xmlns:zimbra="urn:zimbra"
        xmlns:zmail="urn:zimbraMail">
    <soap:Header>
      <soap:context xmlns="urn:zimbra" xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
        <nonotify xmlns=""/>
        <noqualify xmlns=""/>
      </soap:context>
    </soap:Header>
    <soap:Body>
      <zaccount:AuthRequest xmlns="urn:zimbraAccount">
        <account by="name" xmlns="">user</account>
        <password xmlns="">password</password>
      </zaccount:AuthRequest>
    </soap:Body>
    </soap:Envelope>
    And I'm getting an authToken in the response:

    Code:
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Header>
      <context xmlns="urn:zimbra">
        <change token="660"/>
      </context>
    </soap:Header>
    <soap:Body>
    <AuthResponse xmlns="urn:zimbraAccount">
      <authToken>
        mytoken
      </authToken>
      <lifetime>172800000</lifetime>
      <skin>carbon</skin>
    </AuthResponse>
    </soap:Body>
    </soap:Envelope>
    But then I try to use this authToken to call another service :

    Code:
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
        xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
        xmlns:zaccount="urn:zimbraAccount"
        xmlns:zimbra="urn:zimbra"
        xmlns:zmail="urn:zimbraMail">
    <soap:Header>
      <soap:context xmlns="urn:zimbra" xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
        <account by="name" xmlns="">user@domain.com</account>
        <authToken xmlns="">myToken</authToken>
        <nonotify xmlns=""/>
        <noqualify xmlns=""/>
      </soap:context>
    </soap:Header>
    <soap:Body>
      <zmail:GetFolderRequest>
        <folder/>
      </zmail:GetFolderRequest>
    </soap:Body>
    </soap:Envelope>
    And I get this response :

    Code:
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Header>
      <context xmlns="urn:zimbra"/>
    </soap:Header>
    <soap:Body>
      <soap:Fault>
        <soap:faultcode>soap:Client</soap:faultcode>
        <soap:faultstring>no valid authtoken present</soap:faultstring>
        <soap:detail>
          <Error xmlns="urn:zimbra">
            <Code>service.AUTH_REQUIRED</Code>
            <Trace>...</Trace>
          </Error>      
        </soap:detail>
      </soap:Fault>
    </soap:Body>
    </soap:Envelope>
    Do you have an idea of what could be wrong?
    I'm using javax.xml.soap classes to build SOAP messages. The 2 calls are made using the same SOAPConnection.

    Thanks.

  8. #8
    Join Date
    Mar 2011
    Location
    Lansing, MI
    Posts
    17
    Rep Power
    4

    Default

    Same connection should not matter. It looks like your request is fine, but admin may not have permissions for that.

    Maybe try the same request as the calendar's owner, and see if that works.

    We share each user's calendar with admin to give admin access. No access to get folders seems like a different issue.

    IMHO, writing SOAP requests is easier done using templates than using javax.xml.soap. We write each request in .txt file, with template keys, read the template by getting URL from classloader, then push in the data with String.replaceAll(). Of course, this means we have to make sure the data is XML compatible, and javax.xml.soap must take care of that.

  9. #9
    Join Date
    Mar 2012
    Posts
    1
    Rep Power
    3

    Default

    Is there any documentation about the Zimbra Java Client library ..... and where can I find it?

Similar Threads

  1. admin consol blank after 5.0.3 upgarde
    By maumar in forum Administrators
    Replies: 6
    Last Post: 03-21-2008, 06:16 AM
  2. Replies: 12
    Last Post: 02-25-2008, 07:28 PM
  3. Big Fubar on 5 FOSS GA Upgrade
    By uxbod in forum Administrators
    Replies: 24
    Last Post: 01-21-2008, 03:37 AM
  4. Replies: 16
    Last Post: 09-07-2006, 07:39 AM
  5. Fedora Core 3, Clean Install - Not working!
    By pcjackson in forum Installation
    Replies: 17
    Last Post: 03-05-2006, 07:38 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
  •