WSIFMessage outputMessage = operation.createOutputMessage();
WSIFMessage faultMessage = operation.createFaultMessage();
// Create a name and address to add to the addressbook
String nameToAdd = "Chris P. Bacon";
Address addressToAdd =
new Address(
1,
"The Waterfront",
"Some City",
"NY",
47907,
new Phone(765, "494", "4900"));
// Add the name and address to the input message
inputMessage.setObjectPart("name", nameToAdd);
inputMessage.setObjectPart("address", addressToAdd);
// Execute the operation, obtaining a flag to indicate its success
boolean ok=
operation.executeRequestResponseOperation(
inputMessage,
outputMessage,
faultMessage);
assertTrue( "failed to add name and address!!", ok );
/*
* Run iterations of createOperation
*/
testName = testNamePrefix + ".createOperation";
iterations = (TEST_CREATEOP)? getIterations( testName ) : 1;
System.out.println( "running " + iterations + " " + testName + " iterations..." );
for (int i = 0; i < iterations; i++ ) {
Monitor.start( testName );
operation = port.createOperation("getAddressFromName");
Monitor.stop( testName );
}
/*
* Run iterations of executeRequestResponseOperation
*/
testName = testNamePrefix + ".executeOperation";
iterations = (TEST_EXECOP)? getIterations( testName ) : 1;
System.out.println( "running " + iterations + " " + testName + " iterations..." );
for (int i = 0; i < iterations; i++ ) {
operation = port.createOperation("getAddressFromName");
inputMessage = operation.createInputMessage();
outputMessage = operation.createOutputMessage();
faultMessage = operation.createFaultMessage();
inputMessage.setObjectPart("name", nameToAdd);
Monitor.start( testName );
boolean operationSucceeded =
operation.executeRequestResponseOperation(
inputMessage,
outputMessage,
faultMessage);
Monitor.stop( testName );
if (!operationSucceeded) {
System.out.println("Failed to lookup name in addressbook");
assertTrue("executing op returned false!!", false);
}
}
// make sure it all worked
Address addressFound =
(Address) outputMessage.getObjectPart("address");
assertTrue( "returned address not correct!!",
addressToAdd.equals( addressFound) );
Monitor.printResults();