Homepage | About EASA | Contact
package com.easa.ws.client; import com.easa.ws.client.stub.Easa; import com.easa.ws.client.stub.EasaService; import javax.xml.ws.BindingProvider; import org.apache.log4j.Logger; /* * A Java implementation of a Client for the EASA Web Service. * The example easap application used here is the * Mortgage Calculator which can be found in the "examples" * directory under "applications" * */ public class ARM { public static void main(String[] args) { /* Set the URL where the web service is running */ /* The method below requires "service.wsdl" to be downloaded from the server: * http://easaserver1:80/easa-ws/service * * and saved into directory: * * com\easa\ws\client\stub * * in the easa-common.jar archive. * (if the server changes the new WSDL file must be downloaded and saved again) */ EasaService.setUrl("service.wsdl"); /* * Retrieve a proxy to the web service. * The proxy can then be used to call all * the public methods supported by the web service */ Easa easap = new EasaService().getEasaPort(); /* * Set client to maintain session. * This enables the client to use the same session to interact * with the web service instead of creating a new session each * time a method is invoked */ ((BindingProvider)easap).getRequestContext().put( BindingProvider.SESSION_MAINTAIN_PROPERTY,true ); /* * set authentication parameters if necessary. * If the EASA web service is set to require authentication, * then the following parameters must be set */ // ((BindingProvider)easap).getRequestContext().put( // BindingProvider.USERNAME_PROPERTY, "easaws"); // ((BindingProvider)easap).getRequestContext().put( // BindingProvider.PASSWORD_PROPERTY, "easaws"); try{ //invoke business method //used to measure the time taken to start up an easap long timer = System.currentTimeMillis(); System.out.println("starting easap..."); String appId = easap.getPublishedAppId("examples/mortgage_calc"); /* * start the web service session by specifying the relative path * of the easap to use. The easap used here is the Mortgage * Calculator example. When a session is started, a user license * is also checked out. */ easap.startSession(appId); //Report time taken to start the easap System.out.println( "easap started..." + (System.currentTimeMillis()-timer)/1000); /* * Get current run status. * Run status can be one of several statuses such as No Run, * Adding to Queue, Run Completed, Incompleted etc. */ System.out.println(easap.getRunStatus()); /* * invoke getValue method. * The getValue method of the web service end point returns * the value of the dor variable whose name * is supplied as parameter. * Below we read the default Loan Amount and its corresponding * Starting Monthly Payment */ System.out.println( "cell_Basic_Information_loan_amount1 = "+easap.getValue( "cell_Basic_Information_loan_amount1") ); System.out.println( "cell_Basic_Information_starting_monthly_payment = "+easap.getValue( "cell_Basic_Information_starting_monthly_payment") ); System.out.println("setting realbox_Loan_Amount to 100000"); /* * invoke setValue method. * The setValue method of the web service end point sets * the value of the dor variable to the value supplied as parameter. * In this example we use it to set our Loan Amount to 100000 */ easap.setValue("cell_Basic_Information_loan_amount1","100000"); /* * Use the getValue method to read the recomputed * Starting Monthly Payment following the change to Loan Amount above */ System.out.println( "cell_Basic_Information_starting_monthly_payment = "+easap.getValue( "cell_Basic_Information_starting_monthly_payment") ); /* * invoke getProperty method. * The getProperty method of the web service end point reads * the value of the property (supplied as parameter) of a dor * variable (also supplied as parameter). In the example below * we read the value of the Choices: parameter of the * choice_list_Term object. */ //System.out.println( // "cell_Basic_Information_term1= "+easap.getProperty( // "cell_Basic_Information_term1","Choices")); /* * Invoke run actions. * The runActions method of the web service end point invokes an * action that are triggered when a button is pressed. * The name of the button is supplied as parameter. * For example, in this example case, invoking the following code * has the same effect as pressing the "button_Submit" button * which is to submit our Mortgage Calculator Easap */ easap.runActions("button_submit"); /* * We can now repeatedly poll the web service to check * the various states the easap goes through after * it has been submitted. */ for (int i = 0; i <50; i++) { System.out.println( Thread.currentThread().getName()+ " : "+ easap.getRunStatus()); Thread.sleep(1000); } } catch (Exception e) { Logger.getLogger("PrintStackTrace").error(e.getMessage(),e); } finally{ /* * end session. * This method ends the easap session and thus checks back-in * the user license that was being used */ easap.endSession(); } } }