01 package com.bea.medrec.webservices;
02
03 import com.bea.medrec.utils.MedRecLog4jFactory;
04 import com.bea.medrec.value.Record;
05 import com.bea.medrec.webservices.client.MedRecRMWebServicesPortType;
06 import javax.jws.WebMethod;
07 import javax.jws.WebService;
08 import javax.jws.soap.SOAPBinding;
09 import javax.xml.rpc.Stub;
10 import org.apache.log4j.Logger;
11 import weblogic.jws.ServiceClient;
12 import weblogic.jws.WLHttpTransport;
13 import weblogic.wsee.async.AsyncCallContextFactory;
14 import weblogic.wsee.async.AsyncPostCallContext;
15 import weblogic.wsee.async.AsyncPreCallContext;
16
17
18 // Standard JWS annotation that specifies that the name of the Web Service is
19 // "MedRecRMWebServices", its public service name is "MedRecRMWebServices", and the
20 // targetNamespace used in the generated WSDL is "http://www.bea.com/medrec"
21 @WebService(name="PhysicianWebServicesPortType",
22 serviceName="PhysicianWebServices",
23 targetNamespace="http://www.bea.com/medrec")
24
25 // Standard JWS annotation that specifies this is a document-literal-wrapped
26 // Web Service REVIEWME - review comment
27 @SOAPBinding(style=SOAPBinding.Style.DOCUMENT,
28 use=SOAPBinding.Use.LITERAL,
29 parameterStyle=SOAPBinding.ParameterStyle.WRAPPED)
30
31 // WebLogic-specific JWS annotation that specifies the port name is
32 // "PhysicianWebServices", and the context path and service URI used to build
33 // the URI of the Web Service is "ws_phys/PhysicianWebServices"
34 @WLHttpTransport(portName="PhysicianWebServicesPort",
35 contextPath="ws_phys",
36 serviceUri="PhysicianWebServices")
37
38 /**
39 * <p>Physician Web Service that asynchronously invokes the MedRec's reliable
40 * asynchronous webservice.</p>
41 *
42 * @author Copyright (c) 2006 by BEA Systems. All Rights Reserved.
43 */
44 public class PhysicianWebServices {
45
46 private static Logger logger =
47 MedRecLog4jFactory.getLogger(PhysicianWebServices.class.getName());
48
49 // FIXME - need comment here
50 @ServiceClient(serviceName = "MedRecRMWebServices")
51 private MedRecRMWebServicesPortType port;
52
53 /**
54 * <p>Reliable and asynchronously transmits new record to MedRec.</p>
55 *
56 * @param wsServiceUrl
57 * @param pRecordVO
58 */
59 @WebMethod
60 public void addRecord(String wsServiceUrl, Record pRecordVO) throws Exception {
61 logger.info("Sending record to MedRec...");
62 logger.debug("Service end point: "+wsServiceUrl);
63 logger.debug("Record: "+pRecordVO.toString());
64 if (wsServiceUrl == null || wsServiceUrl.equals(""))
65 throw new Exception("Service end point is null.");
66 AsyncPreCallContext apc = AsyncCallContextFactory.getAsyncPreCallContext();
67 apc.setProperty("record", pRecordVO);
68 Stub stub = (Stub)port;
69 stub._setProperty(Stub.ENDPOINT_ADDRESS_PROPERTY, wsServiceUrl);
70 port.addRecordAsync(apc, pRecordVO);
71 }
72
73 /**
74 * <p>Method called once MedRec processes the new record.</p>
75 *
76 * @param apc
77 * @param pRecordVO
78 */
79 public void onAddRecordAsyncResponse(AsyncPostCallContext apc,
80 Record pRecordVO) {
81 logger.info("WS-RM async response: "+pRecordVO.toString());
82 }
83
84 /**
85 * <p>Method called once MedRec processes the new record.</p>
86 *
87 * @param apc
88 * @param t
89 */
90 public void onAddRecordAsyncFailure(AsyncPostCallContext apc, Throwable t) {
91 logger.error("Failed to transmit patient record: ");
92 t.printStackTrace();
93 }
94 }
|