Hi all,
I am using Axis to develop Web services, but until right now I was using
all WS locally. It took about 22milleseconds to execute. Very fast. However
I put them in a LAN, within two machines, and the same Web service took
about 4000 miliseconds to execute. I was astonished! What am I doing wrong?
I put in annexe my Test class in java so you can see what I am actually
doing to run all of them. All four Web services has only one method that
returns OK as a String when it is executed, nothing more than this.
Thus I would like to know what shall I do to make my WS more faster. I am
using axis 1.3.
Thank you so much,
Daniela
public class TestPerformanceExecutionAxisWS{
public static void main(String args[]){
String url[] = new String[4];
url[0] ="http://localhost:8080/webservices/EscalierBeton.jws";
url[1] ="http://localhost:8080/webservices/FournitureBetonENT2.jws";
url[2] ="http://localhost:8080/webservices/FournitureBois.jws";
url[3] ="http://localhost:8080/webservices/FournitureFerENT.jws";
String method = "executeWS";
int n=0;
long startTime = System.currentTimeMillis();
long averageWS=0;
for (int i = 0; i<400;i++){
try{
long startWS = System.currentTimeMillis();
ExecuteWSviaAxis oExecuteWS = new ExecuteWSviaAxis(url[n],method);
n++;
if (n==3) n=0;
String result = oExecuteWS.executeWS();
long finalWS = System.currentTimeMillis();
long totalWS = finalWS-startWS;
averageWS = averageWS+totalWS;
}catch(Exception e){
e.printStackTrace();
}
}
long finalTime = System.currentTimeMillis();
long totalTime = finalTime - startTime;
System.out.println("***************************");
System.out.println("TOTAL TIME:"+totalTime);
System.out.println("AVERAGE TIME:"+averageWS/400);
}
}
/**
*ExecuteWSviaAxis
*/
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
import org.apache.axis.utils.Options;
import javax.xml.rpc.ParameterMode;
public class ExecuteWSviaAxis {
String endpoint;
String method;
public ExecuteWSviaAxis(String urlService, String method){
this.endpoint = urlService;
this.method = method;
}
public String executeWS() throws Exception{
String result="";
try{
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress( new java.net.URL(endpoint) );
call.setOperationName( method );
call.setReturnType( XMLType.XSD_STRING );
System.out.println("***********");
System.out.println("*********** Starting Web service with AXIS
******************");
System.out.println("*********** Service endpoint:"+endpoint);
result = (String) call.invoke(new Object [] {});
System.out.println("*********** Finishing Web service with AXIS
******************");
System.out.println("***********");
System.out.println("ResultadoServiceAxis:" + result);
}catch(Exception e){
System.out.println("ERRO AXIS Method:prepareServiceToExecution
inside MPExecution:");
}
return result;
}
}