The RPC-encoded web services include the following:
The web services consist of a first generation that includes LPClient, LPApplication, LPAsset, and LPNotebook, and a second generation that includes MsiAppOriginator. These services are synchronous, RPC (Remote Procedure Call) style web services. They use simple types, with all types being treated as String data (although field values are converted to their proper data types when inserted in the LeasePak database.
The following is an example of how a LeasePak API web service is created and used in Java:
// these are the required import statements to use the Apache Axis API import org.apache.axis.client.Call; import org.apache.axis.client.Service; import org.apache.axis.encoding.XMLType; // these imports are used to print out SOAP messages import org.apache.axis.MessageContext; import org.apache.axis.Message; import org.apache.axis.AxisFault; // more required imports import javax.xml.namespace.QName; import javax.xml.rpc.ParameterMode; public class LPWebServiceTemplate { // this is a method that allows you to print out the SOAP request and SOAP response // useful for debugging public static void printCallRequestResponse(Call lpcall) throws AxisFault { MessageContext ctx = lpcall.getMessageContext(); Message requestMsg = ctx.getRequestMessage(); Message responseMsg = ctx.getResponseMessage(); System.out.println("SOAP REQUEST : " + requestMsg.getSOAPPartAsString()); System.out.println(); System.out.println("SOAP RESPONSE : " + responseMsg.getSOAPPartAsString()); System.out.println(); } public static void main(String [] args) { try { String lpendpoint = "http://hostname:port/deployed_location/services/service_name"; // where hostname is the name of your host machine, port is your port number, // deployed_location is the root directory where mPower is deployed, and // service_name is the name of the web service (LPClient, LPApplication, MsiAppOriginator, etc.) Service lpservice = new Service(); Call lpcall = (Call)lpservice.createCall(); lpcall.setTargetEndpointAddress(new java.net.URL(lpendpoint) ); // for the LeasePak API web services, the caller must maintain state (session) lpcall.setProperty(call.SESSION_MAINTAIN_PROPERTY,new Boolean(true)); // call to log in lpcall.setOperationName(new QName("urn:LPWebService", "lpMethod") ); // where LPWebService is LPCLient, LPApplication, MsiAppOriginator, etc., and // lpMethod is the method you are executing (for first generation services, you must execute dsConnect first; // for MsiAppOriginator, you can execute createApplication, getMessages, etc.) Type result = lpcall.invoke(new Object[]{optional_arguments}); // where Type is the return data type (boolean, java.lang.String, void, etc.) printCallRequestResponse(lpcall); } catch (Exception e) { System.out.println(e.toString()); } } }
The web services use Web Service Definition Language (WSDL) to generate client proxy classes that allow the user to treat a web service (such as LPClient) as a local object. The documentation includes an example (Java RMI/Apache Axis mp_axis, presented as an HTML document) of LPClient, lpclient_wsdl.java.
The session data is stored in a Java Map. Each object (LPClient, LPApplication, LPAsset, LPNotebook, MsiAppOriginator) has its own
connection to LeasePak and each object maintains a connection to the LeasePak XML driver until dsDisconnect()
is called
(MsiAppOriginator calls dsConnect()
and dsDisconnect()
internally, transparent to the user). Most
errors (or SOAP exceptions) are caught and re-thrown so the program can close the connection. If an unexpected error occurs, connections
and XML drivers could remain open and running. NetSol recommends checking for open connections and running drivers after receiving an error
or exception, and reporting any occurrences of open connections or running drivers to NetSol.