One: The client generated by eclipse, based on axis
Client_sub.getoptions (). Settimeoutinmilliseconds (1000*60);
Client_sub represents a stub object on a client.
such as: Org.apache.axis.client.Call _call=createcall ();
II: Based on Xfire
Service model = new Objectservicefactory (). Create (Taskservice. Class);
Xfireproxyfactory factory = new Xfireproxyfactory (Xfirefactory.newinstance (). Getxfire ());
Taskservice service = (taskservice) factory.create (model, URL);
Client client =client.getinstance (service);
Client.settimeout (10000);
Client.setproperty (Commonshttpmessagesender.http_timeout, string.valueof (10000));
Client.setproperty (Commonshttpmessagesender.disable_keep_alive, "true");
Client.setproperty (Commonshttpmessagesender.disable_expect_continue, "true");
Another kind
Simpleserviceserviceclient serviceclient= New Simpleserviceserviceclient ();
SimpleService Serviceport = Serviceclient.getsimpleserviceport ();
Httpclientparams params = new Httpclientparams ();
Params.setparameter (Httpclientparams.use_expect_continue, Boolean.false);
Set Connection Timeout
Params.setparameter (Httpclientparams.connection_manager_timeout, 2L);
Set Response timeout
Params.setintparameter (Httpclientparams.so_timeout,2);
Client client = client.getinstance (Serviceport);
Client.setproperty (Commonshttpmessagesender.http_client_params, PARAMS);
System.out.println (Serviceport.concatenate ("Xfire1", "Xfire2"));
Three: Based on CXF
1, the client of the stub generated in CXF, in the following manner (CXF2.1.1):
Where Simpleserviceservice is the automatically generated stub class.
Simpleserviceservice srv = new Simpleserviceservice ();
SimpleService Serviceport = Srv.getsimpleserviceport ();
Timeout setting
Client cl = clientproxy.getclient (Serviceport);
Httpconduit http = (httpconduit) cl.getconduit ();
Httpclientpolicy httpclientpolicy = new Httpclientpolicy ();
Httpclientpolicy.setconnectiontimeout (10000);
Httpclientpolicy.setreceivetimeout (1000);
Http.setclient (Httpclientpolicy);
Serviceport.concatenate ("111", "2222");
Quad: JAX-ws
//3,JAX-WS clients: Also use CXF's clientproxy to control HTTP connections:
URL wsdlurl = new URL ("file:///D:/JAVAWorkspace/Repository/prjCXFWS/src/wsdl/prjCXFWS.wsdl");
QName serviceqname = new QName ("http://test.cxfws.com/", "Simpleserviceservice");
QName portqname = new QName ("http://test.cxfws.com/", "Simpleserviceport");
Service service = Service.create (Wsdlurl, serviceqname);
//set Handler
Service.sethandlerresolver (new Requestorderhandlerresolver ()); simpleservice port = (simpleservice) service.getport (Portqname, SimpleService. Class);
Timeout setting
Client cl = clientproxy.getclient (port);
Httpconduit http = (httpconduit) cl.getconduit ();
Httpclientpolicy httpclientpolicy = new Httpclientpolicy ();
Httpclientpolicy.setconnectiontimeout (10000);
Httpclientpolicy.setreceivetimeout (1000);
Http.setclient (Httpclientpolicy);
System.out.println (Port.concatenate ("Srt1", "Srt2"));
WebService Client SetTimeOut