Results 1 to 3 of 3

Thread: Problem sending a SOAP request to Zimbra server

  1. #1
    Join Date
    May 2011
    Posts
    13
    Rep Power
    4

    Default Problem sending a SOAP request to Zimbra server

    Hello,

    I am trying to send a SOAP request to Zimbra server in order to authenticate and perform admin tasks.

    I am sure I am missing a point somewhere but can't find where.

    Here is the SOAP request I am sending:

    Code:
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
    	<SOAP-ENV:Header>
    		<context xmlns="urn:zimbra">
    			<nonotify/>
    			<noqualify/>
    		</context>
    	</SOAP-ENV:Header>
    	<SOAP-ENV:Body>
    		<AuthRequest xmlns="urn:zimbraAccount">
    			<name>admin@domain.com</name>
    			<password>password</password>
    		</AuthRequest>
    	</SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    Here is the java code:

    Code:
    SOAPConnectionFactory sfc = SOAPConnectionFactory.newInstance();
    		SOAPConnection connection = sfc.createConnection();
        	
        	MessageFactory mf = MessageFactory.newInstance();
            SOAPMessage sm = mf.createMessage();
            SOAPHeader sh = sm.getSOAPHeader();
            SOAPBody sb = sm.getSOAPBody();
            
            /* Build soap header */
            QName headerName = new QName("urn:zimbra", "context");
            SOAPHeaderElement headerElement = sh.addHeaderElement(headerName);
            QName noNotifyQName = new QName("nonotify");
            headerElement.addChildElement(noNotifyQName);
            
            QName noQualifyQName = new QName("noqualify");
            headerElement.addChildElement(noQualifyQName);
    
            /* Build soap body */
            QName serviceName = new QName("urn:zimbraAdmin", "AuthRequest");
            SOAPBodyElement bodyElement = sb.addBodyElement(serviceName);
            QName nameQn = new QName("name");
            SOAPElement nameElementValue = bodyElement.addChildElement(nameQn);
            nameElementValue.addTextNode("admin@domain.com");
            QName passwordQn = new QName("password");
            SOAPElement passwordElementValue = bodyElement.addChildElement(passwordQn);
            passwordElementValue.addTextNode("password");
    
            sm.writeTo(System.out);
    
            URL url = new URL("https://server:7071/service/admin/soap");
            
            SOAPMessage response = connection.call(sm, url);
            System.out.println(response.getContentDescription());
            return sm;
    I don't get anything back when making the call. No error in the Zimbra log files.

    Thanks
    Last edited by fgb; 06-13-2011 at 01:18 PM.

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

    Default

    Hi fgb,

    I do not know what is wrong with your source.
    But I think that you better check how zimbra original source code sends AuthRequest.
    You can start from com.zimbra.cs.taglib.tag.LoginTag which is called when you use normal zwc login.
    In the doTag function of the class, zimbra client API com.zimbra.cs.zclient.ZMailbox is used like this;
    ZMailbox mbox = ZMailbox.getMailbox(options);
    This is actually where SOAP AuthRequest is created and sent.

    Or you can use this zimbra client API in your source code.

    Hope it will help you.

  3. #3
    Join Date
    May 2011
    Posts
    13
    Rep Power
    4

    Default

    It finally worked, I was not handling properly the answer I get from Zimbra, it was my fault.

    Thank you for your help!

Similar Threads

  1. Issues after upgrading from 6.0.10 to 7
    By rhorist in forum Administrators
    Replies: 8
    Last Post: 02-25-2011, 07:38 AM
  2. Replies: 12
    Last Post: 02-25-2008, 06:28 PM
  3. [SOLVED] Clamav problem ? What's happening ?
    By aNt1X in forum Installation
    Replies: 23
    Last Post: 02-14-2008, 04:43 AM
  4. Replies: 8
    Last Post: 02-27-2007, 03:10 AM
  5. huge log size
    By rmvg in forum Administrators
    Replies: 5
    Last Post: 01-02-2007, 09:39 AM

Posting Permissions

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