1 4 5 package com.sun.j2ee.blueprints.anyposervice; 6 7 import java.rmi.*; 8 import javax.xml.soap.*; 9 import javax.xml.rpc.server.*; 10 11 import org.w3c.dom.*; 12 import org.w3c.dom.Node ; 13 14 public class AnyPurchaseOrderServiceImpl implements 15 AnyPurchaseOrderServiceSEI,ServiceLifecycle { 16 17 private ServletEndpointContext context; 18 private POXMLUtil xmlUtil; 19 20 public void init(Object context) { 21 this.context = (ServletEndpointContext) context; 22 xmlUtil = new POXMLUtil(); 23 } 24 25 public void destroy() {} 26 27 public SubmitPOResponse submitPO(SubmitPO request) throws InvalidPOException, RemoteException { 28 29 String id = null; 30 SubmitPOResponse reply = null; 31 32 try{ 33 SOAPElement requestdata= request.get_any(); 34 NodeList list = ((Element)requestdata).getElementsByTagName("poId"); 36 37 for (int loop = 0; loop < list.getLength(); loop++) { 38 Node node = list.item(loop); 39 if (node != null) { 40 Node child = node.getFirstChild(); 41 if ((child != null) && child.getNodeValue() != null){ 42 id = child.getNodeValue(); 43 } 44 } 45 } 46 47 SOAPElement replydata = xmlUtil.createSOAPMessage(id); 48 reply = new SubmitPOResponse(); 49 reply.set_any(replydata); 50 51 } catch(Exception exe){ 52 throw new RuntimeException ("AnyPOService Having Problems:"+exe.getMessage(), exe); 53 } 54 55 if(id.equals("100")) 57 throw new InvalidPOException("Invalid ID for the purchase order!!! " + 58 "For demo purposes, we throw " + 59 "an application defined exception for the ID value of 100."); 60 return reply; 61 } 62 } 63 64 | Popular Tags |