Return to the article.
Listing 4. A sample client that explicitly destroys the calculator resource
...
com.ibm.samples.calculator.CalculatorService calculatorService = null;
// Initial Context
javax.naming.InitialContext ic = new javax.naming.InitialContext();
// Lookup calculator SI
// Returns object support javax.xml.rpc.Service
com.ibm.samples.calculator.CalculatorServiceService calculatorServiceSI
= (com.ibm.samples.calculator.CalculatorServiceService)
ic.lookup("java:comp/env/service/CalculatorServiceService");
// Get the calculator SEI
calculatorService = (com.ibm.samples.calculator.CalculatorService)
calculatorServiceSI.getPort(com.ibm.samples.calculator.CalculatorService.class);
if(calculatorService != null)
{
try
{
String acctName = request.getParameter("acctName");
...
boolean delete = false;
if(request.getParameter("delete") != null)
delete = true;
...
javax.xml.soap.SOAPElement SE = calculatorService.getCalculator(acctName);
...
com.ibm.samples.wsa.wsaddr.EndpointReference epr =
com.ibm.samples.wsa.wsaddr.EndpointReference.fromSOAPElement(SE);
...
// Call JAXRPCHelper to associate EPR with account and make it stateful
com.ibm.samples.wsa.utils.JAXRPCHelper.setEPR( (javax.xml.rpc.Stub) calculatorService ,
epr);
// Call a couple of other methods on calculator service
calculatorService.add(add);
calculatorService.sub(sub);
// destroy the ws-resource instance
if(delete) calculatorService.destroy();
...
|
Return to the article.
