Zimbra offers Open Source email server software and shared calendar for Linux and the Mac
Go Back   Zimbra :: Forums > Zimbra Collaboration Suite > Developers

Welcome to the Zimbra :: Forums!
Welcome, if you would like to post a comment please register. We also encourage you to explore all things Zimbra with our team and members of the community.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-13-2011, 11:59 AM
fgb fgb is offline
Junior Member
 
Posts: 8
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..
Reply With Quote
  #2 (permalink)  
Old 06-14-2011, 05:04 PM
Project Contributor
 
Posts: 92
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;
Quote:
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.
Reply With Quote
  #3 (permalink)  
Old 06-15-2011, 11:27 AM
fgb fgb is offline
Junior Member
 
Posts: 8
Default

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

Thank you for your help!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads

Why Join?

Registering let's you ask questions, makes it easier to search, displays any files attached to posts, and notifies you about replies.

blog.zimbra.com




 

SEO by vBSEO ©2011, Crawlability, Inc.