Page 2 of 2 FirstFirst 12
Results 11 to 20 of 20

Thread: Jar For Soap Client

  1. #11
    Join Date
    Sep 2007
    Posts
    9
    Rep Power
    8

    Default success!!

    dkarp .... thanks !!

    This url worked: https://localhost:7071/service/admin/soap

    I was able to successfully add an account.

    Thanks again !!

    __________________________________________________ ________
    For those struggling with SOAP here is my code:

    1] Make sure the 'certificates' issue is sorted out first, we used a commercial certificate.
    2] We used Eclipse IDE on Linux and Zimbra 4.8/Java 1.5
    3] Make sure the commons-httpclient-3.0.jar and commons-codec-1.3.jar match up and make sure you use the correct jar files all around or you run the risk of cross-referencing. Also make sure you have the correct versions of zimbrastore.jar and zimbracommons.jar.

    import java.util.HashMap;
    import java.util.Map;
    import com.zimbra.common.service.ServiceException;
    import com.zimbra.cs.account.Account;
    import com.zimbra.cs.account.soap.SoapProvisioning;


    final static String FNAME = "Joe";
    final static String LNAME = "Shmoe";
    final static String ADDRESS = "101 Market Street";
    final static String CITY = "San Francisco";
    final static String STATE = "CA";
    final static String POSTALCODE = "94105";
    static private Account createZimbraAccount;

    public static void main(String[] args) {

    Map<String, Object> map = new HashMap<String, Object>();
    try {
    map.put("gn", FNAME);
    map.put("sn", LNAME);
    map.put("street", ADDRESS);
    map.put("l", CITY);
    map.put("st", STATE);
    map.put("postalCode", POSTALCODE);
    } catch (Exception e) {
    e.printStackTrace();
    }

    try {
    SoapProvisioning sp = new SoapProvisioning();
    sp.soapSetURI("https://localhost:7071/service/admin/soap");
    sp.soapAdminAuthenticate("admin","password");
    createZimbraAccount = sp.createAccount("a@b.com", "password", map);

    }
    catch(ServiceException se) {
    se.printStackTrace();
    }
    }


    This should help you create a simple zimbra account using SOAP.

    dkarp ... thanks again ....
    Last edited by ozomozo; 01-08-2008 at 02:21 PM.

  2. #12
    Join Date
    Jan 2008
    Posts
    12
    Rep Power
    7

    Default

    Hi Ozomozo,

    Where can I find zimbrastore.jar and zimbracommons.jar?

    Thanks

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

    Default

    They're in the Zimbra OSS distributions. Just unpack and look in /opt/zimbra/lib/jars, I believe.
    Bugzilla - Wiki - Downloads - Before posting... Search!

  4. #14
    Join Date
    Jan 2008
    Posts
    12
    Rep Power
    7

    Default

    Thanks for the reply. I found it in my Zimbra Server....

    In class SoapProvisioning there's a method called preAuthAccount. I am trying to make a Signal Sign On in Zimbra but I allways get a error of authentication failed. Code:account.AUTH_FAILED
    ¿After the call preAuthAccount is there something else needed? Zimbra will open the mailbox of this account automaticaly?

    I tried another option following the steps described in:
    Preauth - Zimbra :: Wiki

    1. append usu1@domain.com|name|0|timestamp
    2. preauthValue = encrypt with HMAC and the zimbraPreauthKey
    3. build the URL with /service/preauth?account=usu1@domain.com&expires=0&timestam p=timestamp&preauth = (preauthValue)

    I am kind of stuck with this issue, any help or hint would be so nice.
    Thanks
    Last edited by Ada; 02-11-2008 at 09:03 AM.

  5. #15
    Join Date
    Jan 2008
    Posts
    12
    Rep Power
    7

    Default

    Checking inside method preAuthAccount,
    uses the parameters in different order than is explained in Zimbra wiki.

    concat the values for account, by, expires, timestamp together
    (in that order, order is definitely important (Zimbra Wiki)


    This is code for preAuthAccount method.
    XMLElement req = new XMLElement(AccountConstants.AUTH_REQUEST);
    Element a = req.addElement(AccountConstants.E_ACCOUNT);
    a.addAttribute(AccountConstants.A_BY, "name");
    a.setText(accountName);
    Element p = req.addElement(AccountConstants.E_PREAUTH);
    p.addAttribute(AccountConstants.A_TIMESTAMP, timestamp);
    p.addAttribute(AccountConstants.A_BY, accountBy);
    p.addAttribute(AccountConstants.A_EXPIRES, expires);
    p.setText(preAuth);
    invoke(req);


    ¿Could be this the problem?
    Anybody has tried this method in SoapProvisioning class?

    Thanks

  6. #16
    Join Date
    Jul 2008
    Posts
    91
    Rep Power
    7

    Default

    I cannot get what you all trying to do...

    I run this code

    Code:
    import java.io.IOException;
    import com.zimbra.common.service.ServiceException;
    import com.zimbra.common.soap.Element;
    import com.zimbra.common.soap.SoapHttpTransport;
    import com.zimbra.cs.account.soap.SoapProvisioning;
    import com.zimbra.cs.service.mail.MailService;
    import com.zimbra.cs.service.account.AccountService;
    import com.zimbra.cs.servlet.ZimbraServlet;
    import com.zimbra.cs.util.Zimbra;
    import com.zimbra.soap.ZimbraSoapContext;
    
    public class TestZClient {
        public static void main(String [] args) throws ServiceException
        {
      SoapProvisioning sp = new SoapProvisioning();
            sp.soapSetURI("https://3.244.4.16:7071/zimbraAdmin/");
            sp.soapAdminAuthenticate("admin","fsloke999");
            System.out.println(sp.GM_ZIMBRA);
        }
    }
    but the warning code is:
    Exception in thread "main" java.lang.NoClassDefFoundError: org/dom4j/DocumentException
    at com.zimbra.cs.account.soap.SoapProvisioning.soapSe tURI(SoapProvisioning.java:89)
    at TestZClient.main(TestZClient.java:45)
    Caused by: java.lang.ClassNotFoundException: org.dom4j.DocumentException
    at java.net.URLClassLoader$1.run(URLClassLoader.java: 200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.j ava:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:3 06)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:276)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:2 51)
    at java.lang.ClassLoader.loadClassInternal(ClassLoade r.java:319)
    ... 2 more
    Java Result: 1
    BUILD SUCCESSFUL (total time: 0 seconds)
    Thank you
    Last edited by fsloke; 09-30-2008 at 08:18 AM.

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

    Default

    Looks like you're missing a library. Add dom4j-1.5.jar to your Java classpath and try again.
    Bugzilla - Wiki - Downloads - Before posting... Search!

  8. #18
    Join Date
    Jul 2008
    Posts
    91
    Rep Power
    7

    Default

    I forgot to update this post when I solve the dom4j-1.5.jar error.

    Here is the second error:
    init:
    deps-jar:
    compile-single:
    run-single:
    log4j:WARN No appenders could be found for logger (org.apache.commons.httpclient.params.DefaultHttpP arams).
    log4j:WARN Please initialize the log4j system properly.
    com.zimbra.cs.zclient.ZClientException: invoke sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderE xception: unable to find valid certification path to requested target, server: 3.244.4.16
    ExceptionId:main:1220409936312:4441cb39ded2325a
    Code:zclient.IO_ERROR
    at com.zimbra.cs.zclient.ZClientException.IO_ERROR(ZC lientException.java:47)
    at com.zimbra.cs.account.soap.SoapProvisioning.invoke (SoapProvisioning.java:189)
    at com.zimbra.cs.account.soap.SoapProvisioning.soapAd minAuthenticate(SoapProvisioning.java:145)
    at TestZClient.main(TestZClient.java:88)
    Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderE xception: unable to find valid certification path to requested target
    at com.sun.net.ssl.internal.ssl.Alerts.getSSLExceptio n(Alerts.java:174)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(S SLSocketImpl.java:1591)
    at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Ha ndshaker.java:187)
    at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Ha ndshaker.java:181)
    at com.sun.net.ssl.internal.ssl.ClientHandshaker.serv erCertificate(ClientHandshaker.java:975)
    at com.sun.net.ssl.internal.ssl.ClientHandshaker.proc essMessage(ClientHandshaker.java:123)
    at com.sun.net.ssl.internal.ssl.Handshaker.processLoo p(Handshaker.java:516)
    at com.sun.net.ssl.internal.ssl.Handshaker.process_re cord(Handshaker.java:454)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRec ord(SSLSocketImpl.java:884)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.perform InitialHandshake(SSLSocketImpl.java:1096)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.writeRe cord(SSLSocketImpl.java:623)
    at com.sun.net.ssl.internal.ssl.AppOutputStream.write (AppOutputStream.java:59)
    at java.io.BufferedOutputStream.flushBuffer(BufferedO utputStream.java:65)
    at java.io.BufferedOutputStream.flush(BufferedOutputS tream.java:123)
    at java.io.FilterOutputStream.flush(FilterOutputStrea m.java:123)
    at org.apache.commons.httpclient.methods.StringReques tEntity.writeRequest(StringRequestEntity.java:150)
    at org.apache.commons.httpclient.methods.EntityEnclos ingMethod.writeRequestBody(EntityEnclosingMethod.j ava:495)
    at org.apache.commons.httpclient.HttpMethodBase.write Request(HttpMethodBase.java:1973)
    at org.apache.commons.httpclient.HttpMethodBase.execu te(HttpMethodBase.java:993)
    at org.apache.commons.httpclient.HttpMethodDirector.e xecuteWithRetry(HttpMethodDirector.java:397)
    at org.apache.commons.httpclient.HttpMethodDirector.e xecuteMethod(HttpMethodDirector.java:170)
    at org.apache.commons.httpclient.HttpClient.executeMe thod(HttpClient.java:396)
    at org.apache.commons.httpclient.HttpClient.executeMe thod(HttpClient.java:324)
    at com.zimbra.common.soap.SoapHttpTransport.invoke(So apHttpTransport.java:234)
    at com.zimbra.common.soap.SoapTransport.invoke(SoapTr ansport.java:297)
    at com.zimbra.common.soap.SoapTransport.invoke(SoapTr ansport.java:261)
    at com.zimbra.cs.account.soap.SoapProvisioning.invoke (SoapProvisioning.java:185)
    ... 2 more
    Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderE xception: unable to find valid certification path to requested target
    at sun.security.validator.PKIXValidator.doBuild(PKIXV alidator.java:285)
    at sun.security.validator.PKIXValidator.engineValidat e(PKIXValidator.java:191)
    at sun.security.validator.Validator.validate(Validato r.java:218)
    at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl. validate(X509TrustManagerImpl.java:126)
    at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl. checkServerTrusted(X509TrustManagerImpl.java:209)
    at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl. checkServerTrusted(X509TrustManagerImpl.java:249)
    at com.sun.net.ssl.internal.ssl.ClientHandshaker.serv erCertificate(ClientHandshaker.java:954)
    ... 24 more
    Caused by: sun.security.provider.certpath.SunCertPathBuilderE xception: unable to find valid certification path to requested target
    at sun.security.provider.certpath.SunCertPathBuilder. engineBuild(SunCertPathBuilder.java:174)
    at java.security.cert.CertPathBuilder.build(CertPathB uilder.java:238)
    at sun.security.validator.PKIXValidator.doBuild(PKIXV alidator.java:280)
    ... 30 more
    BUILD SUCCESSFUL (total time: 2 seconds)
    Is there have any simplest sample code (without error) that can do querying such send email or create account....

    Thank you

  9. #19
    Join Date
    Sep 2008
    Posts
    25
    Rep Power
    7

    Default

    Quote Originally Posted by ozomozo View Post
    dkarp .... thanks !!

    This url worked: https://localhost:7071/service/admin/soap

    I was able to successfully add an account.

    Thanks again !!

    __________________________________________________ ________
    For those struggling with SOAP here is my code:

    1] Make sure the 'certificates' issue is sorted out first, we used a commercial certificate.
    What do you mean with "make sure the certificates issued is sorted out first"?
    I get this error:
    sun.security.validator.ValidatorException

    How can i set a certificate?

  10. #20
    Join Date
    Jun 2009
    Posts
    1
    Rep Power
    6

    Default

    Quote Originally Posted by dkarp View Post
    They're in the Zimbra OSS distributions. Just unpack and look in /opt/zimbra/lib/jars, I believe.
    Hi,

    I am getting this error while testing my SOAP code to create an Email Account..

    Caused by: java.lang.IllegalArgumentException: host parameter is null
    at org.apache.commons.httpclient.HttpConnection.<init >(Unknown Source)
    at org.apache.commons.httpclient.HttpConnection.<init >(Unknown Source)
    at org.apache.commons.httpclient.SimpleHttpConnection Manager.getConnectionWithTimeout(Unknown Source)
    at org.apache.commons.httpclient.HttpMethodDirector.e xecuteMethod(Unknown Source)
    at org.apache.commons.httpclient.HttpClient.executeMe thod(Unknown Source)
    at org.apache.commons.httpclient.HttpClient.executeMe thod(Unknown Source)
    at com.zimbra.common.soap.SoapHttpTransport.invoke(So apHttpTransport.java:258)
    at com.zimbra.common.soap.SoapHttpTransport.invoke(So apHttpTransport.java:226)
    at com.zimbra.common.soap.SoapTransport.invoke(SoapTr ansport.java:315)
    at com.zimbra.common.soap.SoapTransport.invoke(SoapTr ansport.java:279)
    at com.zimbra.cs.account.soap.SoapProvisioning.invoke (SoapProvisioning.java:192)
    at com.zimbra.cs.account.soap.SoapProvisioning.soapAd minAuthenticate(SoapProvisioning.java:145)
    at com.ecommerce.imperia.service.ZimbraMailService.ad dZimbraEmailAccount(ZimbraMailService.java:69)
    at org.jboss.seam.util.Reflections.invoke(Reflections .java:22)
    at org.jboss.seam.intercept.RootInvocationContext.pro ceed(RootInvocationContext.java:31)
    at org.jboss.seam.intercept.SeamInvocationContext.pro ceed(SeamInvocationContext.java:56)
    at org.jboss.seam.transaction.RollbackInterceptor.aro undInvoke(RollbackInterceptor.java:28)
    at org.jboss.seam.intercept.SeamInvocationContext.pro ceed(SeamInvocationContext.java:68)
    at org.jboss.seam.core.BijectionInterceptor.aroundInv oke(BijectionInterceptor.java:77)
    at org.jboss.seam.intercept.SeamInvocationContext.pro ceed(SeamInvocationContext.java:68)
    at org.jboss.seam.transaction.TransactionInterceptor$ 1.work(TransactionInterceptor.java:95)
    at org.jboss.seam.util.Work.workInTransaction(Work.ja va:47)
    at org.jboss.seam.transaction.TransactionInterceptor. aroundInvoke(TransactionInterceptor.java:89)
    at org.jboss.seam.intercept.SeamInvocationContext.pro ceed(SeamInvocationContext.java:68)
    at org.jboss.seam.core.MethodContextInterceptor.aroun dInvoke(MethodContextInterceptor.java:44)
    at org.jboss.seam.intercept.SeamInvocationContext.pro ceed(SeamInvocationContext.java:68)
    at org.jboss.seam.intercept.RootInterceptor.invoke(Ro otInterceptor.java:107)
    at org.jboss.seam.intercept.JavaBeanInterceptor.inter ceptInvocation(JavaBeanInterceptor.java:185)
    at org.jboss.seam.intercept.JavaBeanInterceptor.invok e(JavaBeanInterceptor.java:103)
    at com.ecommerce.imperia.service.ZimbraMailService_$$ _javassist_5.addZimbraEmailAccount(ZimbraMailServi ce_$$_javassist_5.java)
    at org.jboss.el.util.ReflectionUtil.invokeMethod(Refl ectionUtil.java:329)

    ------------------------------------------------------------------------
    And here is my Code:

    import com.zimbra.common.service.ServiceException;
    import com.zimbra.cs.account.Account;
    import com.zimbra.cs.account.soap.SoapProvisioning;

    public void addZimbraEmailAccount(){

    final String FNAME = "Joe";
    final String LNAME = "Shmoe";
    final String ADDRESS = "101 Market Street";
    final String CITY = "San Francisco";
    final String STATE = "CA";
    final String POSTALCODE = "94105";
    Account createZimbraAccount;


    Map<String, Object> map = new HashMap<String, Object>();
    try {
    map.put("gn", FNAME);
    map.put("sn", LNAME);
    map.put("street", ADDRESS);
    map.put("|", CITY);
    map.put("st", STATE);
    map.put("postalcode", POSTALCODE);
    } catch (Exception e) {
    e.printStackTrace();
    }

    try {
    SoapProvisioning sp = new SoapProvisioning();
    sp.soapSetURI("https://localhost:7071/service/admin/soap");
    sp.soapAdminAuthenticate("admin","password");
    createZimbraAccount = sp.createAccount("a@b.com", "password", map);

    }
    catch(ServiceException se) {
    se.printStackTrace();
    }
    }

Similar Threads

  1. Replies: 12
    Last Post: 08-25-2010, 03:37 AM
  2. Deploying Zimbra Client (zimbra.war)
    By zocs in forum Installation
    Replies: 2
    Last Post: 07-25-2007, 06:24 AM
  3. Zimbra client with another server
    By JayBee in forum Developers
    Replies: 6
    Last Post: 02-16-2007, 10:44 PM
  4. Zimbra XUL/AJAX rich client?
    By voidless in forum Users
    Replies: 2
    Last Post: 10-08-2005, 01:22 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
  •