Created
March 18, 2011 19:04
-
-
Save hshemer/876641 to your computer and use it in GitHub Desktop.
set_entry
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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"); | |
//creating a new Name_value array and adding each map entry as 'name' and 'value' | |
Name_value nameValueListSetEntry[] = new Name_value[nameValueMap.size()]; | |
int i=0; | |
for (Entry<String, String> entry : nameValueMap.entrySet()){ | |
Name_value nameValue = new Name_value(); | |
nameValue.setName(entry.getKey()); | |
nameValue.setValue(entry.getValue()); | |
nameValueListSetEntry[i] = nameValue; | |
i++; | |
} | |
//Trying to set a new entry | |
New_set_entry_result setEntryResponse = null; | |
try { | |
setEntryResponse = stub.set_entry(loginResponse.getId(), MODULE_NAME, nameValueListSetEntry); | |
} catch (RemoteException e) { | |
System.out.println("set entry failed. Message: "+e.getMessage()); | |
e.printStackTrace(); | |
} | |
System.out.println("set entry was successful! response id: "+setEntryResponse.getId()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment