Results 1 to 4 of 4

Thread: Sugar, SOAP, Netbeans, java, simple first step Howto

  1. #1
    gunni is offline Sugar Community Member
    Join Date
    Aug 2006
    Location
    Cologne, Germany
    Posts
    402

    Default Sugar, SOAP, Netbeans, java, simple first step Howto

    As i was trying to implement a SOAP client in Java after some steps i found out how to find the start. For future reference to me, and help for others here are the simple steps.
    I used:
    Netbeans 6.9
    Sugar 5.2

    1. Install Netbeans and SOAP plugins (SOAP Web Services, JAX-RPC)
      I found JAX-RPC after adding http://deadlock.netbeans.org/hudson/...updates.xml.gz to the settings under Tools->Plugins
    2. Start a new java Project in Netbeans (Name "testsoap")
    3. Right click your Project, new->Web Service Client
      Choose WSDL URL: http://YOUR_SERVER/YOUR_SUGAR_ROOT/soap.php?wsdl
      Client Style: JAX-RPC Style
      Package: Choose your main package (in this case testsoap)
    4. Just a simple example for how the main program may look like:


    Code:
    package testsoap;
    
    public class Main {
    
        public static void main(String[] args) {
            try{
                Sugarsoap service=new Sugarsoap_Impl();
                SugarsoapPortType port = service.getSugarsoapPort();
                Set_entry_result result=port.login(new User_auth("YOUR_USER_NAME","MD5_OF_PASSWORD","0.1"),"MyApp");
                String session=result.getId();
                System.out.println(result.getError().getName());
                Module_list modulelist=port.get_available_modules(session);
                String[] list=modulelist.getModules();
                int size = list.length;
                for (int i=0; i<size; i++)
                {
                  System.out.println(list[i]);
                }
                String[] searchmodules={"Contacts"};
                String email="THE_EMAIL_YOU_SEARCH_FOR";
                Get_entry_list_result details=port.search_by_module("YOUR_USER_NAME","MD5_OF_PASSWORD",email,searchmodules,0,30);
                Entry_value[] values=details.getEntry_list();
                Name_value[] namevalues=values[0].getName_value_list();
                size = namevalues.length;
                for (int i=0; i<size; i++)
                {
                  System.out.println(namevalues[i].getName());
                  System.out.println(namevalues[i].getValue());
                }
            } catch (Exception ex) {
                System.out.println(ex.getMessage());
                // TODO handle custom exceptions here
            } 
        }
    }
    With this little program it logs in, and outputs the id from the login process, and the available modules, and searches for an email in the Contacts-Module.

    As said just a little Tutorial to start with, and get beyond the real first step.
    Last edited by gunni; 2010-07-02 at 03:22 PM. Reason: Made it more useful with email search in example

  2. #2
    davidboris's Avatar
    davidboris is offline Sugar Community Member
    Join Date
    May 2010
    Posts
    1,525

    Default Re: Sugar, SOAP, Netbeans, java, simple first step Howto

    Hi,

    Thanks for the quick tips. I really appreciate that! Newbies will find it so useful.
    Web : http://www.urdhva-tech.com
    Twitter : @urdhvatech
    Email : contact@urdhva-tech.com
    Blog : Urdhva-Tech
    Skype : urdhvatech

    Our Premium Projects for SugarCRM:
    Premium theme for SugarCRM CE (Community Edition 6.5+ with 4 combinations, Black + Orange/Red/Green/Blue, bootstrap3 based)
    Duplicate detector to avoid duplicate data entry.
    Customer Self Service Portal for All Flavours.
    tagMe A complete tag management for SugarCRM.
    Meeting Map Reminder Meeting reminder with Gmap in Email

  3. #3
    emoti02 is offline Junior Member
    Join Date
    Apr 2010
    Posts
    3

    Default Re: Sugar, SOAP, Netbeans, java, simple first step Howto

    First of all, kudos to Gunni to making this first tutorial so simple for newbies like me.. this code actually works on NetBeans and is probably the only example that works on NetBeans !!

    I have gotten the code to work.. made modifications, but a couple of doubts remain. I would appreciate if someone could help me please (I am a total newbie) -

    1) What is "Sugarsoap_Impl()" ?
    I can't see this as any other Java class or a method on the Sugar SOAP. Where is this code getting its reference from ?

    My aim is to package this whole project in a JAR file and use it on another system, and just want to make sure I am not missing out on something.

    Thanks in advance for your response..
    Sahil Sharma

  4. #4
    nebula Guest

    Default Re: Sugar, SOAP, Netbeans, java, simple first step Howto

    Kudos for coming out with such a simple approach to get newbies started. This is probably the only article out there that can make it work on NetBeans!!

    Just a couple of doubts I had about this implementation -
    1) What is "Sugarsoap_Impl" ??
    I can't seem to find another class, or function or Soap method by that name (I am a total newbie!)

    2) What is the difference between soap calls using Soap.php in the root directory, and the one inside services/v2 ?
    To me both the WSDLs appear quite similar.

    Thanks a lot in advance to all the gurus for helping out

    Best Regards,
    Sahil Sharma

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, 06:42 PM
  2. Replies: 9
    Last Post: 2010-11-23, 06:05 PM
  3. Java sugar soap error
    By yadaom in forum Developer Help
    Replies: 1
    Last Post: 2010-05-25, 09:16 AM
  4. Delete Note via sugar soap java API
    By othmanelmoulat in forum General Discussion
    Replies: 8
    Last Post: 2009-06-09, 03:30 PM
  5. Java basic example please (netbeans)
    By rbroomfield in forum Developer Help
    Replies: 4
    Last Post: 2009-02-09, 07:23 AM

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
  •