Results 1 to 2 of 2

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
    364

    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 02:22 PM. Reason: Made it more useful with email search in example

  2. #2
    davidboris is offline Sugar Community Member
    Join Date
    May 2010
    Posts
    1,113

    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.
    Thumbs up.

    Skype ID - david__boris

    SugarForge Projects:

    WYSIWYG now in studio!(Version 1.1 is out now!)

    Sugar Feeds on your personalized home pages like iGoogle, My Yahoo!, etc.

    Fab Tools! > Dashlet Not Followed Opportunities for past six Months

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