try{
JaxWsProxyFactoryBean factoryBean = new JaxWsProxyFactoryBean();
factoryBean.getInInterceptors().add(new LoggingInInterceptor());
factoryBean.getOutInterceptors().add(new LoggingOutInterceptor());
factoryBean.setServiceClass(AutoPackServiceIntf.class);
factoryBean.setAddress("http://10.241.0.105:17000/TEST");
AutoPackServiceIntf factory = (AutoPackServiceIntf) factoryBean.create();
Client client = ClientProxy.getClient(factory);
HTTPConduit conduit = (HTTPConduit) client.getConduit();
HTTPClientPolicy policy = new HTTPClientPolicy();
policy.setConnectionTimeout(30000); //連接超時(shí)時(shí)間
policy.setReceiveTimeout(120000); //請(qǐng)求超時(shí)時(shí)間.
conduit.setClient(policy);
System.out.println(factory.getFirstUnitCramp("1"));
}catch(WebServiceException ex){
long l2 = System.currentTimeMillis();
System.out.println((l2-l1)+"ms");
System.out.println("連接異常");
}
Lyyb2001