|
Test webapp | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectadriani.webapp.util.SimpleHTTPClient
public class SimpleHTTPClient
Simple java client emulating a web browser. This class allows to invoke a web service
using HTTP binding directly from the command line. For training reasons we use this class also in the
test_client.jsp
JSP page, but in that situation this client is not useful as when launched
from the command line (i.e. it's not so useful to emulate a browser inside a real browser).
Field Summary | |
---|---|
java.lang.String |
action
SOAP ACTION: NOT USED at the moment (see above) |
java.lang.String |
end_Tag
|
protected java.lang.String |
leadingName
Beginning of each logging message |
java.lang.String |
namespace
DEFAULT VALUES |
protected boolean |
simple
If true this client assume the SOAP request contains only one parameter. |
protected java.lang.String |
soapRequest
Contains the complete SOAP request for web services expecting multiple input parameters. |
java.lang.String |
start_Tag
|
static boolean |
VERBOSE
CLASS ATTRIBUTES |
Constructor Summary | |
---|---|
SimpleHTTPClient()
|
Method Summary | |
---|---|
java.lang.StringBuffer |
call(java.lang.String server,
java.lang.String param)
Call the web service. |
java.lang.StringBuffer |
getResponse(java.net.HttpURLConnection connection)
Read the response from the stream bound to the connection and store it
into a StringBuffer object. |
java.lang.StringBuffer |
getXML(java.lang.String param,
boolean text)
Produce the XML string to be used in the SOAP request message. |
void |
init(java.lang.String ns,
java.lang.String request)
Call the web service. |
void |
init(java.lang.String ns,
java.lang.String tag_1,
java.lang.String tag_2)
Used to initialize this client when the SOAP request contains only one parameter. |
static void |
main(java.lang.String[] args)
Main method used to call the SimpleHTTPClient from the command line. |
void |
printRequest(java.lang.String param)
Print the SOAP request message on the STOUT (for testing and debug purposes). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static boolean VERBOSE
public java.lang.String namespace
public java.lang.String start_Tag
public java.lang.String end_Tag
protected boolean simple
true
this client assume the SOAP request contains only one parameter.
The parameter should be set to false
when this client is run within the Tomcat container
(i.e. called from a JSP page). On the opposite, if the client is executed from the command line
(e.g. from the run.bat file), this parameter must be set to true
!
protected java.lang.String soapRequest
protected java.lang.String leadingName
public java.lang.String action
Constructor Detail |
---|
public SimpleHTTPClient()
Method Detail |
---|
public static void main(java.lang.String[] args)
public void init(java.lang.String ns, java.lang.String tag_1, java.lang.String tag_2)
call(String server, String param)
method will require only the parameter's value.init(String ns, String request)
method instead.
ns
- the namespace used to define the XML elements in the service's WSDL.tag_1
- the opening tag of the input element.tag_2
- the closing tag of the output element.public void init(java.lang.String ns, java.lang.String request)
ns
- the namespace used to define the XML elements in the service's WSDL.request
- the complete SOAP request, ready to be submitted to the web service.public java.lang.StringBuffer call(java.lang.String server, java.lang.String param)
server
- the URL of the target server hosting the web service.param
- the string value to be used for the main request element.public java.lang.StringBuffer getXML(java.lang.String param, boolean text)
param
- the string value to be used for the main request element.text
- if true the XML string is produced in user-friendly format. Use always false
when producing an actual XML SOAP message.public void printRequest(java.lang.String param)
the
- input parameter to be wrapped in the SOAP message.public java.lang.StringBuffer getResponse(java.net.HttpURLConnection connection)
connection
and store it
into a StringBuffer
object.
|
Build 10/01/2013 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |