KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > j2ee > blueprints > anyposervice > AnyPurchaseOrderServiceImpl


1 /* Copyright 2005 Sun Microsystems, Inc. All rights reserved. You may not modify, use, reproduce, or distribute this software except in compliance with the terms of the License at:
2  http://developer.sun.com/berkeley_license.html
3  $Id: AnyPurchaseOrderServiceImpl.java,v 1.14 2005/12/01 20:53:15 yutayoshida Exp $ */

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 JavaDoc;
13
14 public class AnyPurchaseOrderServiceImpl implements
15         AnyPurchaseOrderServiceSEI,ServiceLifecycle {
16
17     private ServletEndpointContext context;
18     private POXMLUtil xmlUtil;
19
20     public void init(Object JavaDoc 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 JavaDoc id = null;
30         SubmitPOResponse reply = null;
31
32         try{
33             SOAPElement requestdata= request.get_any();
34             //extract the PO ID
35
NodeList list = ((Element)requestdata).getElementsByTagName("poId");
36             
37             for (int loop = 0; loop < list.getLength(); loop++) {
38                 Node JavaDoc node = list.item(loop);
39                 if (node != null) {
40                     Node JavaDoc 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 JavaDoc exe){
52             throw new RuntimeException JavaDoc("AnyPOService Having Problems:"+exe.getMessage(), exe);
53         }
54
55         //this is done just to illustrate throwing an application specific exception
56
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