1 6 7 8 9 package com.sun.j2ee.blueprints.docoriented.client.objectposervice; 10 11 12 13 import java.rmi.*; 14 15 import javax.naming.*; 16 17 import javax.xml.rpc.*; 18 19 20 21 import com.sun.j2ee.blueprints.docoriented.client.*; 22 23 24 25 32 33 public class SchemaPOServiceBD { 34 35 36 37 private ServiceLocator serviceLocator; 38 39 40 41 public SchemaPOServiceBD(){ 42 43 serviceLocator = new ServiceLocator(); 44 45 } 46 47 48 49 58 59 public String submitPO(com.sun.j2ee.blueprints.docoriented.client.PurchaseOrder po) throws RequestHandlerException { 60 61 62 63 try { 64 65 SchemaDefinedPurchaseOrderServiceSEI port = (SchemaDefinedPurchaseOrderServiceSEI) 66 67 serviceLocator.getServicePort(JNDINames.SCHEMA_SERVICE_REF, SchemaDefinedPurchaseOrderServiceSEI.class); 68 69 70 71 73 Address shipTo = new Address(); 74 75 shipTo.setStreet(po.getShipTo().getStreet()); 76 77 shipTo.setCity(po.getShipTo().getCity()); 78 79 shipTo.setState(po.getShipTo().getState()); 80 81 shipTo.setPostalCode(po.getShipTo().getPostalCode()); 82 83 84 85 Address billTo = new Address(); 86 87 billTo.setStreet(po.getBillTo().getStreet()); 88 89 billTo.setCity(po.getBillTo().getCity()); 90 91 billTo.setState(po.getBillTo().getState()); 92 93 billTo.setPostalCode(po.getBillTo().getPostalCode()); 94 95 96 97 com.sun.j2ee.blueprints.docoriented.client.LineItem[] items = po.getItems(); 98 99 LineItem item1 = new LineItem(); 100 101 item1.setItemId(items[0].getItemId()); 102 103 item1.setQuantity(items[0].getQuantity()); 104 105 item1.setPrice(items[0].getPrice()); 106 107 108 109 LineItem item2 = new LineItem(); 110 111 item2.setItemId(items[1].getItemId()); 112 113 item2.setQuantity(items[1].getQuantity()); 114 115 item2.setPrice(items[1].getPrice()); 116 117 118 119 LineItem[] lineItems = new LineItem[2]; 120 121 lineItems[0] = item1 ; 122 123 lineItems[1] = item2 ; 124 125 126 127 PurchaseOrder order = new PurchaseOrder(); 128 129 order.setPoId(po.getPoId()); 130 131 order.setCreateDate(po.getCreateDate()); 132 133 order.setShipTo(shipTo); 134 135 order.setBillTo(billTo); 136 137 order.setItems(lineItems); 138 139 140 141 String ret = port.submitPO(order); 142 143 return ret; 144 145 146 147 } catch(InvalidPOException ipoe){ 148 149 ipoe.printStackTrace(System.err); 150 151 throw new RequestHandlerException("Request Handler Exception: Service Endpoint Application-Defined Exception "+ipoe.getMessage(), ipoe); 152 153 } catch(RemoteException re){ 154 155 re.printStackTrace(System.err); 156 157 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); 158 159 } 160 161 } 162 163 } 164 165 166 167 | Popular Tags |