"ShoppingCart_EJBPortType" // portTypeName
);
WSIFPort port = service.getPort();
WSIFOperation operation;
WSIFMessage inputMessage;
WSIFMessage outputMessage;
WSIFMessage faultMessage;
String customerNumber;
String tempString;
Address address;
ShoppingCart shoppingCart;
Item item = null;
CreditCardInfo creditCardInfo;
AirMilesContainer airMilesContainer;
Integer currentTotal = null;
Long orderConfirmationNumber;
Integer itemQuantity;
Object part;
boolean operationSucceeded;
// -----------------------------------------------------------------------------------------------------
operation = port.createOperation("createOperation");
inputMessage = operation.createInputMessage();
outputMessage = operation.createOutputMessage();
faultMessage = operation.createFaultMessage();
debug("\n---> Invocation (home): public ShoppingCart create(java.lang.String firstName, java.lang.String lastName, org.apache.wsif.ejb.sample.shop.Address address, java.lang.String customerNumber) throws org.apache.wsif.ejb.sample.shop.CreateException, javax.ejb.CreateException, java.rmi.RemoteException");
inputMessage.setObjectPart("firstName", "Albert");
inputMessage.setObjectPart("lastName", "Einstein");
address = new Address("Berlin", "Unter den Linden");
inputMessage.setObjectPart("address", address);
inputMessage.setObjectPart("customerNumber", "AE001");
operationSucceeded =
operation.executeRequestResponseOperation(
inputMessage,
outputMessage,
faultMessage);
assertTrue("createOperation failed!!", operationSucceeded);
// -----------------------------------------------------------------------------------------------------
// First add something to the basket
operation = port.createOperation("addItemOperation");
inputMessage = operation.createInputMessage();
outputMessage = operation.createOutputMessage();
faultMessage = operation.createFaultMessage();
debug("\n---> Invocation (remote): public Item addItem(java.lang.String itemNumber, java.lang.String itemName, int itemQuantity) throws org.apache.wsif.ejb.sample.shop.OutOfStockException, java.rmi.RemoteException, org.apache.wsif.ejb.sample.shop.InvalidItemException");
inputMessage.setObjectPart("itemNumber", "100123");
inputMessage.setObjectPart("itemName", "Pocket calculator");
inputMessage.setIntPart("itemQuantity", 1);
operationSucceeded =
operation.executeRequestResponseOperation(
inputMessage,
outputMessage,
faultMessage);
assertTrue("addItemOperation failed!!", operationSucceeded);
if (operationSucceeded) {
assertTrue(
"addItemOperation (EJB) did not return an Item Object!!",
outputMessage.getObjectPart("item") instanceof Item);
debug(outputMessage.getObjectPart("item"));
} else {
part = faultMessage.getObjectPart("invalidItemException");
if (part != null) {
debug(faultMessage.getName() + ":\n" + part);
} else {
part = faultMessage.getObjectPart("outOfStockException");
if (part != null) {
debug(faultMessage.getName() + ":\n" + part);
} else {
debug("ERROR: Unknown fault message!");
}
}
}
// -----------------------------------------------------------------------------------------------------
// Test an "Input Only" operation by invoking the emptyBasket method
operation = port.createOperation("emptyOrderOperation");
inputMessage = operation.createInputMessage();
debug("\n---> Invocation: public void emptyOrder(String customerNumber)");
inputMessage.setObjectPart("customerNumber", "AE001");
operation.executeInputOnlyOperation(inputMessage);
// -----------------------------------------------------------------------------------------------------
// Add to the basket again - the basket should be empty before this if previous operation worked!!
operation = port.createOperation("addItemOperation");
inputMessage = operation.createInputMessage();
outputMessage = operation.createOutputMessage();
faultMessage = operation.createFaultMessage();
debug("\n---> Invocation (remote): public Item addItem(java.lang.String itemNumber, java.lang.String itemName, int itemQuantity) throws org.apache.wsif.ejb.sample.shop.OutOfStockException, java.rmi.RemoteException, org.apache.wsif.ejb.sample.shop.InvalidItemException");
inputMessage.setObjectPart("itemNumber", "100123");
inputMessage.setObjectPart("itemName", "Pocket calculator");
inputMessage.setIntPart("itemQuantity", 5);
operationSucceeded =
operation.executeRequestResponseOperation(
inputMessage,
outputMessage,
faultMessage);
assertTrue("addItemOperation failed!!", operationSucceeded);