Results 1 to 9 of 9

Thread: SOAP API from Java

  1. #1
    leandro20 is offline Sugar Community Member
    Join Date
    Oct 2007
    Posts
    15

    Default SOAP API from Java

    I´m trying to use sugarcrm soap api from java application and I'm having some problems. I´ve searched a lot and I didn´t found any example.

    Can anybody help me with some exmaple or something please?
    Last edited by leandro20; 2007-10-10 at 01:12 PM.

  2. #2
    Join Date
    Feb 2007
    Location
    San Jose, CA
    Posts
    1,169

    Default Re: SOAP API from Java

    Please read this post.
    Susie Williams

  3. #3
    sacramentojoe is offline Sugar Community Member
    Join Date
    Nov 2005
    Posts
    447

    Default Re: SOAP API from Java

    Quote Originally Posted by leandro20
    I´m trying to use sugarcrm soap api from java application and I'm having some problems. I´ve searched a lot and I didn´t found any example.

    Can anybody help me with some exmaple or something please?
    Well, it's hard to give you some help due to the fact that there are a million and one SOAP client libraries for Java.
    I personally have used the Apache Axis library and I've had good luck with it.
    However, now that JEE 5 has been out for a while, I'd look into using that long with one of their java.xml.* classes.

  4. #4
    leandro20 is offline Sugar Community Member
    Join Date
    Oct 2007
    Posts
    15

    Default Re: SOAP API from Java

    Quote Originally Posted by sacramentojoe
    Well, it's hard to give you some help due to the fact that there are a million and one SOAP client libraries for Java.
    I personally have used the Apache Axis library and I've had good luck with it.
    However, now that JEE 5 has been out for a while, I'd look into using that long with one of their java.xml.* classes.
    Yes I know there are million soap clients. I am using Axis but y have some problems in login. Please if you have some examples you can help me.
    Zimbra CRM has examples and his own api for soap client, I thought sugar has something like this

  5. #5
    sacramentojoe is offline Sugar Community Member
    Join Date
    Nov 2005
    Posts
    447

    Default Re: SOAP API from Java

    Sugar does have examples in the Wiki but it's by using the PHP NuSoap client.

    http://www.sugarcrm.com/wiki/index.p...tical_Examples

  6. #6
    julian's Avatar
    julian is offline Sugar Team Member
    Join Date
    Sep 2004
    Posts
    1,639

    Default Re: SOAP API from Java

    Hello leandro20,

    What kind of problems are you having? Is the SOAP message not going through, or is Sugar returning an error message? If you see any error messages, either from your application or from Sugar, please post them.

    Thanks,
    Julian Ostrow
    Systems and Applications Engineer
    SugarCRM Inc.

  7. #7
    leandro20 is offline Sugar Community Member
    Join Date
    Oct 2007
    Posts
    15

    Default Re: SOAP API from Java

    Quote Originally Posted by julian
    Hello leandro20,

    What kind of problems are you having? Is the SOAP message not going through, or is Sugar returning an error message? If you see any error messages, either from your application or from Sugar, please post them.

    Thanks,
    How can I work with complexTypes? I did something like this using Axis from java

    Call call = (Call) service.createCall();
    String username = "test";
    String pass = "test";
    String v = "0.1";
    UserAuth auth = new UserAuth(username, pass, v);

    call.setTargetEndpointAddress(new java.net.URL(endpoint));

    call.setOperationName("login");

    call.registerTypeMapping(UserAuth.class, UserAuth.QNAME,
    new org.apache.axis.encoding.ser.BeanSerializerFactory (
    UserAuth.class, UserAuth.QNAME),
    new org.apache.axis.encoding.ser.BeanDeserializerFacto ry(
    UserAuth.class, UserAuth.QNAME));

    call.addParameter("user_auth", UserAuth.QNAME, ParameterMode.IN);
    call.addParameter("application_name", XMLType.XSD_STRING,
    ParameterMode.IN);

    This is for login service. UserAuth is a simple class with those attributes and his getterss and setters.
    That is ok? I have to do something similir with complexTypes of the results?

    I have this exception java.net.MalformedURLException: no protocol: index.php?module=Users&action=SetTimezone
    Last edited by leandro20; 2007-10-16 at 03:47 PM.

  8. #8
    julian's Avatar
    julian is offline Sugar Team Member
    Join Date
    Sep 2004
    Posts
    1,639

    Default Re: SOAP API from Java

    Hello leandro20,

    I'm not 100% how to work with complex types, as I'm not familiar with Java, but I can address the error you're seeing. Try connecting to your Sugar server /soap.php?wsdl instead of something like /index.php. The URL should look something like:

    http://www.example.com/sugar/soap.php?wsdl

    For the complex types... PHP works with them as an array-- is there something similar you can construct in Java? You should be able to find a generic example of SOAP complex types with Java through google.
    Julian Ostrow
    Systems and Applications Engineer
    SugarCRM Inc.

  9. #9
    spoon is offline Junior Member
    Join Date
    Jan 2008
    Posts
    3

    Default Re: SOAP API from Java

    First of all, I found that you do not have to use call.invoke() to talk to SugarCRM. Instead, you can use login() and many other higher level methods, which are generated by the Axis package.

    com.bizsoln.sugarcrm.Sugarsoap service = new com.bizsoln.sugarcrm.SugarsoapLocator();
    com.bizsoln.sugarcrm.SugarsoapPortType port = service.getsugarsoapPort(
    new java.net.URL("http://localhost/sugarcrm/soap.php" ) );
    com.bizsoln.sugarcrm.User_auth userAuth = new com.bizsoln.sugarcrm.User_auth();
    userAuth.setUser_name("myUserId");
    userAuth.setPassword(Secure.getDigest("myPassword" ));
    userAuth.setVersion("0.1");
    com.bizsoln.sugarcrm.Set_entry_result loginRes = port.login(userAuth, "myAppName");

    System.out.println(loginRes + "; rc=" + loginRes.getError().getNumber());

    The Java classes can be generated with the following command on Windows:

    @set AXISDIR="D:\home\spoon\pj\axis"
    @set CLASSPATH=%AXISDIR%\axis.jar
    @set CLASSPATH=%CLASSPATH%;%AXISDIR%\axis-ant.jar
    @set CLASSPATH=%CLASSPATH%;%AXISDIR%\commons-discovery.jar
    @set CLASSPATH=%CLASSPATH%;%AXISDIR%\commons-logging.jar
    @set CLASSPATH=%CLASSPATH%;%AXISDIR%\jaxrpc.jar
    @set CLASSPATH=%CLASSPATH%;%AXISDIR%\log4j-1.2.8.jar
    @set CLASSPATH=%CLASSPATH%;%AXISDIR%\saaj.jar
    @set CLASSPATH=%CLASSPATH%;%AXISDIR%\wsdl4j.jar
    java -cp %CLASSPATH% org.apache.axis.wsdl.WSDL2Java -o . -d Session -p com.bizsoln.sugarcrm soap.php.xml

    where soap.php.xml is downloaded from http://localhost/sugarcrm/soap.php?wsdl

    In addition to UserAuth class you mentioend, other complex types that the web services accept are also generated with the above command. Please look around the generated classes.

    Good luck!

    S.Poon
    http://www.bossmiles.net
    *** A Business Application User Community ***
    *** You Smile, I Smile and We All Smile! ***
    Last edited by spoon; 2008-01-17 at 02:12 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Sugar Soap Server and java apache axis client interop
    By gilberto in forum Developer Help
    Replies: 1
    Last Post: 2011-04-04, 05:42 PM
  2. SOAP API Login Failiure
    By myunus in forum Help
    Replies: 2
    Last Post: 2010-12-07, 09:20 AM
  3. Relating Accounts to Contacts using SOAP API
    By datla27 in forum Developer Help
    Replies: 3
    Last Post: 2007-07-05, 06:36 AM
  4. Replies: 1
    Last Post: 2007-04-19, 01:27 AM
  5. Soap API problem
    By Sabicho in forum Developer Help
    Replies: 13
    Last Post: 2007-02-26, 03:51 PM

Bookmarks

Posting Permissions

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