Magazine
 
Quick Review:Ajax
 
Understanding quality of service for Web services Improving the performance of your Web services

import org.apache.soap.encoding.*;
import org.apache.soap.rpc.*;
import org.apache.soap.util.xml.*;
import mytimer.Timer;
public class EchoServiceProxy
{
private Call call = new Call();
private URL url = null;
private String SOAPActionURI = “”;
private SOAPMappingRegistry smr = call.getSOAPMappingRegistry();
public EchoServiceProxy() throws MalformedURLException
{
call.setTargetObjectURI(“urn:echoservice-service”);
call.setEncodingStyleURI(“http://schemas.xmlsoap.org/soap/encoding/”);
this.url = new URL(“http://localhost:8080/soap/servlet/rpcrouter”);
this.SOAPActionURI = “urn:echoservice-service”;
}
public synchronized void setEndPoint(URL url)
{
this.url = url;
}
public synchronized URL getEndPoint()
{
return url;
}
public synchronized java.lang.String echo
(java.lang.String meth1_inType1) throws SOAPException
{
if (url == null)
{
throw new SOAPException(Constants.FAULT_CODE_CLIENT,
“A URL must be specified via “ +
“EchoServiceProxy.setEndPoint(URL).”);
}
call.setMethodName(“echo”);
Vector params = new Vector();
Parameter meth1_inType1Param = new Parameter(“meth1_inType1”,
java.lang.String.class, meth1_inType1, null);
params.addElement(meth1_inType1Param);
call.setParams(params);
// Start a Timer
Timer timer = new Timer();
timer.start();
Response resp = call.invoke(url, SOAPActionURI);
// Stop the Timer
timer.stop();
// Print the response time by calculating the difference
System.out.println(“Response Time = “ + timer.getDifference());

Apr 2008 | Java Jazz Up | 46
 
previous
index
next
 
Pages: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,

30
, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,   Download PDF