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
- 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 - Start a new java Project in Netbeans (Name "testsoap")
- 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) - 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.
Bookmarks