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

[3714 byte] By [dingfeldera] at [2007-10-2 17:00:24]
# 1

Apache SOAP is obsolete. You shouldn't be using it in the first place. Apache Axis, as you've noted,is the evolution from SOAP and is the current implentation of SOAP engines that you should probably be using.

You're creating a WS client by using JAX-RPC. Axis also achieves WS calls using JAX-RPC. So by asking if using Axis will improve your speed issues, then the answer is no because you are actually using the same implementation both methods (Apache SOAP vs Apache Axis). I'm not sure if Axis speeds up the instantiation of a Call object, which seems to be the issue you are concerned about.

MrButtheada at 2007-7-13 18:13:54 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2

ok, that confirms my suspicion that axis would be better to use.

The end goal of this application is to have a server app which is db enabled and is adding rows to the db as fast as it can, and n number of clients who are each interested in what data is currently in the db.

Each client will be requesting the server to tell them all the data that it has inserted since their last request (it stores the recent data in cache).

Ideally, each client will ask the server for the updated data as fast as it can, perhaps every 1 or 2 seconds. Having said that, I need to have the client prepare it's soap call, make the request, wait for the server to respond, and get the message back, all in under a second or 12. If a single method call is going to take over a second, this may not work.

dingfeldera at 2007-7-13 18:13:54 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...