lpclient_wsdl.java
  1 import LPClient.*;
  2 
  3 
  4 /*
  5  * for java use the following command to generate the LPClient wsdl java files
  6  *
  7  * java org.apache.axis.wsdl.WSDL2Java -pLPClient http://joea:8080/mpower/services/LPClient?wsdl
  8  *
  9  * then execute 
 10  * javac LPClient/*.java
 11  *
 12  * next 
 13  * javac lpclient_wsdl.java
 14  *
 15  * then to run the program type ( make sure . is in your CLASSPATH environment variable )
 16  * java lpclient_wsdl
 17  */
 18 public class lpclient_wsdl
 19    {
 20         public static void main(String args[]) throws Exception
 21         {
 22 
 23                 /** 
 24                  * the next line actually creates a service locator
 25                  * we need the locator because we need to tell the locator 
 26                  * to maintain session  
 27                  */
 28                 LPClientInterfaceServiceLocator locator = new LPClientInterfaceServiceLocator();
 29 
 30                 /**
 31                  * setup maintain session this way successive WSDL calls 
 32                  * will NOT create a new session each time 
 33                  */
 34                 locator.setMaintainSession(true);
 35                 
 36                 /**
 37                  * this is where we actually create an instance of our client Object
 38                  */
 39                 LPClientInterface clientObj = locator.getLPClient();
 40                 if ( clientObj == null ) {
 41                         System.out.println("Error has occured, could not create client Object.");
 42                         return;
 43                 }
 44            
 45                 /**
 46                  * connect to the wsdl service
 47                  */
 48                 boolean res = clientObj.dsConnect();
 49                 System.out.println( "Connection Status = " + res );
 50 
 51                 /**
 52                  * the connectino status should return true on success
 53                  */
 54                 if ( res ) {
 55                         /**
 56                          * set this to true for debugging
 57                          * it defaults to false
 58                          */
 59                         //clientObj.dsSetDebugMode(true);
 60 
 61                         /**
 62                          * for client fetching we need number of the client
 63                          * editClient() ALWAYS returns a STRING 
 64                          * which should contain either INFO or ERROR
 65                          * if it returns anything other than INFO 
 66                          * then an error has probably occured
 67                          *
 68                          * if there was a severe error then it should throw a RemoteException or SOAP fault 
 69                          *
 70                          * to get the info message call getInfoMessage()
 71                          * to get the error message call getErrorMessage()
 72                          */
 73                         String result = clientObj.editLessee("62");
 74                         if ( result.equals("INFO") ) {
 75                                 System.out.println( "INFO message = " + clientObj.getInfoMessage() );
 76                         } else {
 77                                 System.out.println("Result was " + result);
 78                         }
 79                         
 80                         /**
 81                          * to see what the old address was
 82                          * call getAddress1
 83                          */
 84                         String ans = clientObj.getAddress1();
 85                         System.out.println("Client Street Address = " + ans);
 86 
 87                         /**
 88                          * to set the new street address
 89                          * call setAddress1()
 90                          */ 
 91                         clientObj.setAddress1("111 Anza Blvd");
 92         
 93                         /**
 94                          * to update the database record call updateLessee() 
 95                          * just like editLessee() it should return INFO or ERROR or throw a RemoteException
 96                          */
 97                         result = clientObj.updateLessee();
 98                         if ( result.equals("INFO") ) {
 99                                 System.out.println( "INFO message = " + clientObj.getInfoMessage() );                   
100                         } else if ( result.equals("ERROR") ) {
101                                 System.out.println("Result error = " + clientObj.getErrorMessage());
102                         }
103                         ans = clientObj.getInfoMessage();
104                         System.out.println("Did it work? = " + ans);    
105 
106                         /**
107                          * lastly close this transaction and destroy the session 
108                          */
109                         clientObj.dsDisconnect();
110                         System.out.println("We should have disconnected by now!");
111                 }
112 
113         }
114 }
115