Results 1 to 10 of 10

Thread: Java Soap Notification Example

Hybrid View

  1. #1
    Join Date
    Aug 2011
    Posts
    10
    Rep Power
    4

    Default Java Soap Notification Example

    Hi.

    I try to connect our Spring App with Zimbra. I get ldap auth and calendar management working, but i don't find any infomations about the SOAP Notifications system.

    I need notification events for new incoming mails on all accounts inside a domain.

    To get all mailboxes i use this code

    Code:
    private List<ZMailbox>	mailboxList	= new ArrayList<ZMailbox>();
    Code:
    try {
    	SoapProvisioning spAdmin = new SoapProvisioning();
    	spAdmin.soapSetURI(adminURL);
    	spAdmin.soapAdminAuthenticate(this.username, this.password);
    	Domain domain = spAdmin.getDomainByName("mydomain.net");
    	List<Account> accounts = domain.getAllAccounts();
    	for (Account account : accounts) {
    		logger.debug("ACCOUNT: "+account.getName());
    		Options options = new Options(spAdmin.getAuthToken().getValue(), adminURL);
    		options.setTargetAccount(account.getName());
    		options.setTargetAccountBy(AccountBy.name);
    		ZMailbox mbox = new ZMailbox(options);
    		this.mailboxList.add(mbox);
    	}
    } catch (ServiceException e) {
    }
    TimerTask for send NoOp request to keep soap session alive
    Code:
    Iterator<ZMailbox> mailboxIter = mailboxList.iterator();
    while (mailboxIter.hasNext()) {
    	try {
    		ZMailbox mbox = mailboxIter.next();
    		mbox.noOp();
    	} catch (ServiceException e) {
    		e.printStackTrace();
    	}
    }
    but how can i get the notifications about new mails in each postbox?

    greets Rizzi

  2. #2
    Join Date
    Aug 2011
    Posts
    10
    Rep Power
    4

    Default

    Has no one an idea? i can't figure out to get the notifications.

  3. #3
    Join Date
    Oct 2009
    Location
    Tokyo
    Posts
    113
    Rep Power
    6

    Default

    As far as I remember, NoOp SOAP response includes the notifiation you want and you have to keep sending NoOp requests at some interval(polling)
    or send NoOp request and keep the HTTP connection(long polling) to receive notification.

  4. #4
    Join Date
    Aug 2011
    Posts
    10
    Rep Power
    4

    Default

    Hi..
    Thanks for the comment.

    I sent NoOp Request inside a timer, but NoOp is void and has no return value
    or miss understand somethink

    greets Rizzi

  5. #5
    Join Date
    Oct 2009
    Location
    Tokyo
    Posts
    113
    Rep Power
    6

    Default

    NoOp function is implemented like this;
    Code:
    public void noOp() throws ServiceException {
            invoke(newRequestElement(MailConstants.NO_OP_REQUEST));
        }
    So how about directly calling invoke method like this and keep the return to some variables in your source code so you can look into the response, can't you?
    Could you try that?

    By the way, if your source code works, you basically keep sending NoOp requests to all users in some interval.
    Am i right?
    If so, it could consume a lot of system resource.
    How about implementing callback function which is called when every message is received?

    You can see the short explanation about it here;
    Yutaka-Notes about Extensible Classes In ZimbraStore - Zimbra :: Wiki

  6. #6
    Join Date
    Aug 2011
    Posts
    10
    Rep Power
    4

    Default

    Hi,

    i try to build an server module, but i have to integrate the mail sync in our java spring application. the customer wants it this way

    Quote Originally Posted by yutaka View Post
    NoOp function is implemented like this;
    Code:
    public void noOp() throws ServiceException {
            invoke(newRequestElement(MailConstants.NO_OP_REQUEST));
        }
    So how about directly calling invoke method like this and keep the return to some variables in your source code so you can look into the response, can't you?
    Could you try that?
    There ist no response

    Code:
    <NoOpResponse xmlns="urn:zimbraMail"/>
    any other idea?

    greets rizzi

  7. #7
    Join Date
    Aug 2011
    Posts
    10
    Rep Power
    4

    Default

    Ok Thanks. I give it a try.

    greets Rizzi

  8. #8
    Join Date
    Aug 2011
    Posts
    10
    Rep Power
    4

    Default

    Hi.

    I think the LmtpCallback is the better way, but i can't find the method to get the LmtpBackend, for adding my custom callback function in the SoapProvisioning.

    greets Rizzi

  9. #9
    Join Date
    Oct 2009
    Location
    Tokyo
    Posts
    113
    Rep Power
    6

    Default

    AFAIK, you can not do that with SoapProvisioning.

    You have to create Zimbra Extension module which include your own class with your custom callback function like following;
    » Zimbra :: Blog

    You just implement extension's init function in which you register your own callback function to ZimbraLmtpBackend class with something like this;

    ZimbraLmtpBackend.addCallback(<yourownclass>.getIn stance());
    ZimbraLmtpBackend.addCallback(QuotaWarning.getInst ance());

  10. #10
    Join Date
    Aug 2011
    Posts
    10
    Rep Power
    4

    Default

    hi.

    i see that the notify i need is in the header of the response, but i don't find a way to get the header

    greets rizzi

Similar Threads

  1. access zimbra from java using soap
    By aldm in forum Developers
    Replies: 2
    Last Post: 02-20-2011, 04:37 PM
  2. zmzimletctl deploy zimbra_posixaccount.zip - ERROR -
    By todd_dsm in forum Administrators
    Replies: 0
    Last Post: 04-02-2009, 01:41 PM
  3. [SOLVED] Get EMAIL details with SOAP in JAVA
    By rkmorgan in forum Developers
    Replies: 5
    Last Post: 10-11-2007, 09:05 AM
  4. How to consume zimbra SOAP API in my java application
    By Hemant Shrivastava in forum Developers
    Replies: 34
    Last Post: 12-24-2006, 12:24 AM
  5. Replies: 0
    Last Post: 12-04-2006, 08: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
  •