speed of basic soap vs axis
Hello folks, I'm expereinced with client server communication and java but webservices are a bit new to me so please be patient :)
I'm attempting to write my first real soap app and a java client to commnicate with it, and first started off going through some tutorials I found on the web. Following their instructions, I successfully ran a hello world app using apache 2x, tomcat 5x and soap 2.3.1
the tutorial is:
http://www.onjava.com/pub/a/onjava/2002/02/27/tomcat.html?page=1
the client code is:
publicstaticvoid main(String[] args)throws Exception{
URL url =new URL ("http://localhost:8080/soap/servlet/rpcrouter");
Integer p1 =new Integer(args[0]);
Integer p2 =new Integer(args[1]);
// Build the call.
Call call =new Call();
call.setTargetObjectURI("urn:onjavaserver");
call.setMethodName("subtract");
call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
Vector params =new Vector();
params.addElement(new Parameter("p1", Integer.class, p1,null));
params.addElement(new Parameter("p2", Integer.class, p2,null));
call.setParams (params);
// make the call: note that the action URI is empty because the
// XML-SOAP rpc router does not need this. This may change in the
// future.
Response resp = call.invoke(url,"" );
// Check the response.
if ( resp.generatedFault() ){
Fault fault = resp.getFault ();
System.out.println("The call failed: ");
System.out.println("Fault Code= " + fault.getFaultCode());
System.out.println("Fault String = " + fault.getFaultString());
}
else{
Parameter result = resp.getReturnValue();
System.out.println(result.getValue());
}
}
The app works fine, except it seems slow to me.
I modified this code to add timing statements and have noticed that in the hello world app, the initial call method
Call call =new Call();
takes over a second to run, which seems slow to me.
modifying it a bit more, I notice the first time I do
call.setMethodName("subtract");
Response resp = call.invoke(url,"" );
takes just over 1 second, then repeated calls from the same method take only 30ms.
I have 2 questions:
1. Is there a faster way to do this same code? My client will be making repeated calls to the server very quickly and a second of lag will be quite noticable.
2. Is using axis instead of generic soap the say to go? i.e. is it going to be a lot faster?
Cheers,
Ding

