Import org.apache.cxf.endpoint.Client;
Import Org.apache.cxf.frontend.ClientProxy;
Import Org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
Import Org.apache.cxf.transport.http.HTTPConduit;
Import Org.apache.cxf.transports.http.configuration.HTTPClientPolicy;
public class Webserviceutil {private static final long connect_timeout = 1000L * 5;
Private static final Long recive_timeout = 1000L * 15; /** * Proxy way to get WebService client [CXF] (this method mainly functions to set the timeout time) */@SuppressWarnings ("unchecked") public static <T> T getclient (class<t> classz, String URL)
{Jaxwsproxyfactorybean factory = new Jaxwsproxyfactorybean ();
Factory.setaddress (URL);
Factory.setserviceclass (CLASSZ);
T obj = (t) factory.create ();
Client proxy = clientproxy.getclient (obj);
Httpconduit conduit = (httpconduit) proxy.getconduit ();
Httpclientpolicy policy = new Httpclientpolicy ();
Policy.setconnectiontimeout (connect_timeout);
Policy.setreceivetimeout (recive_timeout);
Conduit.setclient (Policy); Return obj; }} url= http://127.0.0.1:8080/****?wsdl generate client code: Wsimport-s D:\cos\pa-p Com.customer.service.client.paramTypeService -keep HTTP://127.0.0.1:8080/****?WSDL Use example Queryserviceporttype client = Webserviceutil.getclient (
Queryserviceporttype.class, URL);
String Resultstr=client.getphotospath (jsonobj.tostring ());