1、 XFIRE方式,调用WebService
通过WebSerice获取数据
<span style="white-space:pre"> </span>/********调用接口加速测试**** ***************************/
HttpClientParams params = new HttpClientParams();
// 避免'Expect: 100-continue' handshake
params.setParameter(HttpClientParams.USE_EXPECT_CONTINUE,Boolean.FALSE);
//设置ws连接超时时间
params.setParameter(HttpClientParams.CONNECTION_MANAGER_TIMEOUT, 100L);
<span style="white-space:pre"> </span>//通过设置以上参数,可以调整访问时间过长的问题
Long start22 = System.currentTimeMillis();
Client client2 = new Client(new URL("http://192.168.67.164:5888/services/EsbRunTimeService?wsdl"));
client2.setProperty(CommonsHttpMessageSender.HTTP_CLIENT_PARAMS,params);
Object[] results1122 = client2.invoke("retrieveServiceCommStateList",new Object[] { "12fcebe" });
System.out.println(results1122[0].toString());
System.out.print("相应时间:"+(System.currentTimeMillis() - start22));
2、
AXIS方式调用WebService
String param = "";
Service service = new Service();
Long start = System.currentTimeMillis();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new java.net.URL("http://192.168.67.164:5888/services/EsbRunTimeService?wsdl"));
call.setOperationName(new QName("http://www.apusic.com/esb/EsbRunTimeService",
"queryServiceList"));
call.addParameter("sysCode", org.apache.axis.Constants.XSD_STRING,
javax.xml.rpc.ParameterMode.IN);
call.setReturnType(org.apache.axis.Constants.XSD_STRING);
try {
Object ret = (Object) call.invoke(new Object[] { "" });
System.out.println("The return value is:" + ret.toString());
System.out.println("响应时间:"+(System.currentTimeMillis() - start));
return;
} catch (Exception e) {
e.printStackTrace();
}
<span style="white-space:pre"> </span>