You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by 詹赵林 <zh...@163.com> on 2011/04/09 04:29:14 UTC

Why AXIS2 so solw at first time

Dear All

         When I use RPCServiceClient to call the Axis2 web services on the local machine,it is very fast。But when I use RPCServiceClient to call the Axis2 web services on the remote machine,it's very slowly,expecially on the first time I call the Axis2.After each call I wait for a moment.when the waittime exceed 30 seconds,it's very slow ,just like the first time.The web services I used is axis2's example "services/Version".
         When I call the Axis2 on the remote machine continuously,the result is :
             1,wait0seconds,use 17516 milliseconds
             2,wait1seconds,use 15 milliseconds
             3,wait2seconds,use 16 milliseconds
             4,wait3seconds,use 16 milliseconds
             5,wait4seconds,use 15 milliseconds
             6,wait5seconds,use 16 milliseconds
             7,wait6seconds,use 15 milliseconds
             8,wait7seconds,use 16 milliseconds
             9,wait8seconds,use 16 milliseconds
             10,wait9seconds,use 16 milliseconds
             …………………………………………………………………………………………
             …………………………………………………………………………………………
             …………………………………………………………………………………………
             30,wait29seconds,use 15 milliseconds
             31,wait30seconds,use 16 milliseconds
             32,wait31seconds,use 15 milliseconds
             33,wait32seconds,use 17281 milliseconds
             34,wait33seconds,use 17282 milliseconds
             35,wait34seconds,use 17281 milliseconds
             36,wait35seconds,use 17406 milliseconds
 
         The source Code is:

         public static void  test() throws ServiceException{
  long time0,time1,time2,time3;
  try {
   time0 = System.currentTimeMillis();
   String method="getVersion";
   String ret = null;
   RPCServiceClient rpcClient = new RPCServiceClient();
   Options options = rpcClient.getOptions();
   EndpointReference targetEPR = new EndpointReference("http://168.5.128.92:7201/axis2/services/Version");
   options.setTo(targetEPR);
   options.setTimeOutInMilliSeconds(120000);
   QName opPrint = new QName(NAMESPACE, method);
   Class[] returnType = { String.class };
   Object[] opAddEntryArgs = new Object[]{null};
   for(int i=0;i<100;i++){ 
    time1 = System.currentTimeMillis();
    Object[] retVal = rpcClient.invokeBlocking(opPrint,opAddEntryArgs,returnType);
    time2 = System.currentTimeMillis();
    System.out.println((i+1)+",wait"+ i +"seconds,use "+ (time2-time1)+" milliseconds");
    Thread.sleep(1000 * (i+1));
   }
   rpcClient.cleanup();
  } catch (Exception e) {
   throw new ServiceException(e);
  }
 }
 
 
 Thank you.