Skip to content

Instantly share code, notes, and snippets.

@hshemer
hshemer / gist:876700
Created March 18, 2011 19:42
get_entry
//getting an entry (the one we just set)
//setting up parameters for get_entry
Link_name_to_fields_array[] link_name_to_fields_array = null;
String[] select_fields = null;
Get_entry_result_version2 getEntryResponse = null;
//trying to get entry
try {
getEntryResponse = stub.get_entry(loginResponse.getId(), MODULE_NAME, setEntryResponse.getId(), select_fields , link_name_to_fields_array);
} catch (RemoteException e) {
@hshemer
hshemer / gist:876641
Created March 18, 2011 19:04
set_entry
//setting a new entry
//setting up parameters for set_entry call.
//creating a name value list array from a hash map. This is not necessary
//just more elegant way to initialize and add name values to an array.
HashMap<String, String> nameValueMap = new HashMap<String, String>();
nameValueMap.put("first_name", "foo");
nameValueMap.put("last_name", "bar");
nameValueMap.put("description", "this is a contact created from a SOAP web service call");
nameValueMap.put("email1", "foo@bar.com");
//login
//setting up parameters for login method
User_auth auth = new User_auth();
auth.setUser_name(USER_NAME);
auth.setPassword(PASSWORD);
//sending an empty name_value_list
Name_value nameValueListLogin[] = null;
//trying to login
//trying to create a stub
SugarsoapBindingStub stub = null;
try {
stub = new SugarsoapBindingStub(url, new Service());
} catch (AxisFault e) {
System.out.println("stub creation failed. Message: "+e.getMessage());
e.printStackTrace();
}
System.out.println("stub created successfully!");
@hshemer
hshemer / gist:876522
Created March 18, 2011 17:48
Main+Endpoint
public class SOAPClient {
private static final String ENDPOINT_URL = "http://localhost:8888/Mango/build/rome/builds/ent/sugarcrm/service/v3/soap.php";
private static final String USER_NAME = "admin";
private static final String PASSWORD = "0cc175b9c0f1b6a831c399e269772661";
private static final String APPLICATION_NAME = "sugarcrm";
private static final String MODULE_NAME = "Contacts";
public static void main (String args[]){
@hshemer
hshemer / gist:876515
Created March 18, 2011 17:44
Constant definition
private static final String ENDPOINT_URL = "http://localhost:8888/Mango/build/rome/builds/ent/sugarcrm/service/v3/soap.php";
private static final String USER_NAME = "admin";
private static final String PASSWORD = "0cc175b9c0f1b6a831c399e269772661";
private static final String APPLICATION_NAME = "sugarcrm";
private static final String MODULE_NAME = "Contacts";