|
soap tutorial | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectadriani.jws.template.SimpleClient
public class SimpleClient
A very simple command line class offering a main()
method to allow invocation of the
web service methods directly on the command line.
If all the necessary environment variables are correctly defined it should be possible to run
this client writing:
java -cp %CLASSPATH% adriani.jws.template.client.SimpleClient
This class can be launched specifying the input parameters for the web service, choosing between two
different approaches: in the emulate mode the client will invoke the business logic
directly, bypassing the ADB structure. In the actual mode the client will invoke
the actual skeleton class of the service.
For details run SimpleClient -h
.
Field Summary | |
---|---|
static java.lang.String |
BLANK
Static final value stored as class field to improve performances. |
java.lang.String[] |
default_data
The string array containing the default hard-coded SOAP request parameters. |
static java.lang.String |
EMPTY
Static final value stored as class field to improve performances. |
boolean |
emulate
If true invokes a method like SimpleClient.testMethodName() , which emulates the
web service (without using the ADBBean classes). |
java.lang.String[] |
format_data
The string array containing the default hard-coded SOAP request parameters. |
int |
howMany
Number of input parameters necessary to fill the input SOAP request (for current method). |
java.lang.String[] |
information_data
The string array containing the default hard-coded SOAP request parameters. |
protected static java.lang.String |
leadingName
Beginning of each logging message produced by this class. |
protected static WSLogger |
logger
Retrieving the logger instance to be used for this class (static). |
static java.lang.StringBuffer |
NULL
Static final value stored as class field to improve performances. |
static java.lang.String |
ZERO
Static final value stored as class field to improve performances. |
Constructor Summary | |
---|---|
SimpleClient()
|
Method Summary | |
---|---|
void |
formatDate(java.lang.StringBuffer[] param)
This method is invoked only if the client is run in the actual mode. |
java.util.Calendar |
getCalendarValue(java.lang.StringBuffer value)
Parse an element of the input string, returning the parsed calendar value. |
java.util.Date |
getDateValue(java.lang.StringBuffer value)
Parse an element of the input string, returning the parsed date value. |
void |
getInformation(java.lang.StringBuffer[] param)
This method is invoked only if the client is run in the actual mode. |
int |
getIntValue(java.lang.String[] string,
int index)
Parse an element of the input array, returning the parsed integer value. |
int |
getIntValue(java.lang.StringBuffer[] buffer,
int index)
Parse an element of the input array, returning the parsed integer value. |
java.lang.StringBuffer[] |
getParameters(java.lang.String[] args,
int method,
int start)
Extract the SOAP parameters list from the input args string array, starting from the
start index position. |
static void |
main(java.lang.String[] args)
Main method used to call the web service from the command line, forwarding action to the run(String[] args) method. |
void |
manageOptions(java.lang.String[] args)
Manage all the possible options available from the command line. |
java.lang.StringBuffer |
printHelp()
Print some help about the SimpleClient command line options on the STDOUT. |
void |
run(java.lang.String[] args,
int method)
If the client is run in the emulate mode the method forwards action to one the testXXX()
methods, which invokes the service logic using the hard-coded input parameters. |
void |
testCodeBlock(java.lang.String[] buffer)
General test, used as a place-holder to write brand new code-block. |
void |
testConfiguration()
Test method used to verify that the static code block in the GeneralService class is found
and correctly executed. |
void |
testDatabase()
Test method used to verify that the static code block in the Database class is found
and correctly executed. |
void |
testFormatDate(java.lang.StringBuffer[] param)
Invokes the ServiceLogic.getFormatDate() method using the wrappers defined in the wrappers
package. |
void |
testGetInformation(java.lang.StringBuffer[] param)
Invokes the ServiceLogic.getInformation() method using the wrappers defined in the wrappers
package. |
void |
testLogger()
Test the logging system. |
void |
testQuery(java.lang.StringBuffer[] buffer)
Execute a simple dummy SQL query to verify the format of the JDBC result set retrieved from the database. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public int howMany
public java.lang.String[] default_data
public java.lang.String[] information_data
public java.lang.String[] format_data
public boolean emulate
true
invokes a method like SimpleClient.testMethodName()
, which emulates the
web service (without using the ADBBean
classes). Otherwise, if false
, invokes
the actual skeleton class implementing the web service, which should be a method like
SimpleClient.methodName()
public static final java.lang.String EMPTY
public static final java.lang.String BLANK
public static final java.lang.String ZERO
public static final java.lang.StringBuffer NULL
protected static WSLogger logger
protected static java.lang.String leadingName
Constructor Detail |
---|
public SimpleClient()
Method Detail |
---|
public static void main(java.lang.String[] args)
run(String[] args)
method.
args
- the standard input string array, usually read from STDIN.run(String[] args, int method)
public void run(java.lang.String[] args, int method)
testXXX()
methods, which invokes the service logic using the hard-coded input parameters.
args
- the standard input string array, usually read from STDINmethod
- the web service method to be invoked (if 0 we'll use the default one, usually the first method)public void manageOptions(java.lang.String[] args)
SimpleClient
are executed by calling:java -cp %CLASSPATH% adriani.jws.template.client.SimpleClient -t n
n
parameter select one of the following test:WSLogger
class.GeneralService
class in order to verify that
the configuration and initialization sequence is executed correctly.
args
- the input string arraypublic void testGetInformation(java.lang.StringBuffer[] param)
ServiceLogic.getInformation()
method using the wrappers defined in the wrappers
package. This method is useful when it's necessary to test the web service logic without using the
ADBBean
classes produces by Axis2 wsdl2java tool.ServiceLogic.getOutput()
method performed here
should almost reflect the actual implementation of the web service, with just two differences:WrapperIn
object is constructed using the WrapperIn.setXXX()
methods,
while in the skeleton class a constructor like WrapperIn(ADBBean element)
is used.WrapperOut.getXXX()
methods, in
order to print these data on the STDOUT, while the skeleton class returns the whole
ADBBean
object given by WrapperOut.getElement()
.
param
- the string buffer array containing all the input datapublic void testFormatDate(java.lang.StringBuffer[] param)
ServiceLogic.getFormatDate()
method using the wrappers defined in the wrappers
package. This method is useful when it's necessary to test the web service logic without using the
ADBBean
classes produces by Axis2 wsdl2java tool.ServiceLogic.getOutput()
method performed here
should almost reflect the actual implementation of the web service, with just two differences:WrapperIn
object is constructed using the WrapperIn.setXXX()
methods,
while in the skeleton class a constructor like WrapperIn(ADBBean element)
is used.WrapperOut.getXXX()
methods, in
order to print these data on the STDOUT, while the skeleton class returns the whole
ADBBean
object given by WrapperOut.getElement()
.
param
- the string buffer array containing all the input datapublic void getInformation(java.lang.StringBuffer[] param)
ADBBean
objects are produced using the input parameters, in order to
respect the structure of the input ADBBean
element. In the same way, the resulting
output data are retrieved from the output ADBBean
object, as returned by the skeleton,
then are printed on the STDOUT.
param
- the string buffer array containing all the input datapublic void formatDate(java.lang.StringBuffer[] param)
ADBBean
objects are produced using the input parameters, in order to
respect the structure of the actual input ADBBean
element. In the same way, the resulting
output data are retrieved from the output ADBBean
object, as returned by the skeleton,
then are printed on the STDOUT.
param
- the string buffer array containing all the input datapublic void testLogger()
public void testConfiguration()
GeneralService
class is found
and correctly executed. In this way we verify that all the static configuration and initialization
of the web service is executed in the right order.
public void testDatabase()
Database
class is found
and correctly executed. Moreover, when this method is invoked, some meta-data about the database's
connections and related pools are printed on the STDOUT.
public void testQuery(java.lang.StringBuffer[] buffer)
argument[1]
parameter, while the input parameter used to fill the
statement (if available) is specified by the argument[2]
parameter. In other words this
method must be called using following syntax:SimpleClient -q n p
n
select of the following DAO methods:
buffer
- the input string array, converted into a StringBuffer
objectGeneralDAO.getRecord(int targetDB, String label, String query, int cols)
,
GeneralDAO.getRecordSet(int targetDB, String label, String query, int cols)
,
GeneralDAO.getFunction(int targetDB, String label, String query, Object[] param, int type)
,
GeneralDAO.getProcedure(int targetDB, String label, String query, Object[] param, int cols, int[] inout)
,
GeneralDAO.getFunctionPipe(int targetDB, String label, String query, int cols)
public void testCodeBlock(java.lang.String[] buffer)
SimpleClient
using the -t 4
option.
buffer
- the input args
string arraypublic java.lang.StringBuffer[] getParameters(java.lang.String[] args, int method, int start)
args
string array, starting from the
start
index position. If the input array is null
the default values,
stored as class fields, will be used.
args
- the standard input string array, usually taken from an hard-coded arraymethod
- index of the method which the parameters belongstart
- the index of the first args
element to be used as SOAP parameter
StringBuffer
arraypublic java.lang.StringBuffer printHelp()
SimpleClient
command line options on the STDOUT.
public int getIntValue(java.lang.String[] string, int index)
string
- the input string array, converted into a String
objectindex
- the index of the element to be extracted
public int getIntValue(java.lang.StringBuffer[] buffer, int index)
buffer
- the input string array, converted into a StringBuffer
objectindex
- the index of the element to be extracted
public java.util.Date getDateValue(java.lang.StringBuffer value)
value
- the input date in string format
public java.util.Calendar getCalendarValue(java.lang.StringBuffer value)
value
- the input date in string format
|
Build 18/09/2012 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |