1 4 5 package com.sun.j2ee.blueprints.docoriented.client.anyposervice; 6 7 import java.rmi.*; 8 9 import javax.xml.soap.*; 10 11 import org.w3c.dom.*; 12 import org.w3c.dom.Node ; 13 14 import com.sun.j2ee.blueprints.docoriented.client.*; 15 16 20 public class AnyPOServiceBD { 21 22 private ServiceLocator serviceLocator; 23 24 25 public AnyPOServiceBD(){ 26 serviceLocator = new ServiceLocator(); 27 } 28 29 public String submitPO(PurchaseOrder po) throws RequestHandlerException { 30 try { 31 boolean wrapper = false; 34 AnyPurchaseOrderServiceSEI port = (AnyPurchaseOrderServiceSEI) 35 serviceLocator.getServicePort(JNDINames.ANY_SERVICE_REF, AnyPurchaseOrderServiceSEI.class); 36 SOAPElement requestSOAPElem = po.toXMLSOAPElement(wrapper); 37 SubmitPO req = new SubmitPO(); 38 req.set_any(requestSOAPElem); 39 SubmitPOResponse response = port.submitPO(req); 40 SOAPElement responseSOAPElem = response.get_any(); 41 NodeList list = ((Element)responseSOAPElem).getElementsByTagNameNS("urn:AnyPurchaseOrderService","poID"); 42 String ret = null; 43 for (int loop = 0; loop < list.getLength(); loop++) { 44 Node node = list.item(loop); 45 if (node != null) { 46 Node child = node.getFirstChild(); 47 if ((child != null) && child.getNodeValue() != null){ 48 ret = child.getNodeValue(); 49 } 50 } 51 } 52 return ret; 53 } catch(InvalidPOException ipoe){ 54 ipoe.printStackTrace(System.err); 55 throw new RequestHandlerException("Request Handler Exception: Service Endpoint Application-Defined Exception "+ipoe.getMessage(), ipoe); 56 } catch(RemoteException re){ 57 re.printStackTrace(System.err); 58 throw new RuntimeException ("The web service you are trying to access is not available. A possible reason could be that the service has not been deployed yet. "+ re.getMessage(), re); 59 } 60 } 61 } 62 63 | Popular Tags |