1 4 5 package com.sun.j2ee.blueprints.anytypeposervice; 6 7 import java.rmi.*; 8 9 import javax.ejb.*; 10 import javax.xml.soap.*; 11 12 import org.w3c.dom.*; 13 import org.w3c.dom.Node ; 14 15 public class AnyTypePurchaseOrderServiceBean implements SessionBean { 16 17 private SessionContext sc; 18 private POXMLUtil xmlUtil; 19 20 public AnyTypePurchaseOrderServiceBean() {} 21 22 public String submitPO(SOAPElement request) throws InvalidPOException, RemoteException { 23 String poID = null; 24 SOAPElement reply = null; 25 try { 26 NodeList list = ((Element)request).getElementsByTagName("poId"); 27 for (int loop = 0; loop < list.getLength(); loop++) { 28 Node node = list.item(loop); 29 if (node != null) { 30 Node child = node.getFirstChild(); 31 if ((child != null) && child.getNodeValue() != null){ 32 poID = child.getNodeValue(); 33 } 34 } 35 } 36 } catch (Exception exe) { 37 throw new EJBException("AnyTypePOService Having Problems:"+exe.getMessage(), exe); 38 } 39 if(poID.equals("100")) 41 throw new InvalidPOException("Invalid ID for the purchase order!!! " + 42 "For demo purposes, we throw " + 43 "an application defined exception for the ID value of 100."); 44 return poID; 45 } 46 47 public void ejbCreate() throws CreateException { 49 xmlUtil = new POXMLUtil(); 50 } 51 52 public void setSessionContext(SessionContext sc) { 53 this.sc = sc; 54 } 55 56 public void ejbRemove(){} 57 58 public void ejbActivate() {} 59 60 public void ejbPassivate() {} 61 } 62 63 | Popular Tags |