How to fix invoke CXF webService connection timeout
Hi,
I run into a issue that class in osgi bundle invokes CXF webService with HTTPS approach. Please look at following code:
URL wsdlURL = new URL(strURL.toString()); WebService4AEM_Service ss = new WebService4AEM_Service(wsdlURL, SERVICE_NAME); WebService4AEM port = ss.getWebService4AEMPort(); log.info("Invoking login..."); java.lang.String _login_arg0 = username; java.lang.String _login_arg1 = password; java.lang.String _login__return = port.login(_login_arg0, _login_arg1); log.info("Login FullAccessToken = " + _login__return);When run at line " port.login(....) " , background throws exceptional message as following:
javax.xml.ws.WebServiceException: Failed to access the WSDL at: https://w18.globalsight.com:443/globalsight/aemServices/WebService4AEM?wsdl. It failed with: Connection timed out: connect. at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.tryWithMex(RuntimeWSDLParser.java:151) at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:133) at com.sun.xml.internal.ws.client.WSServiceDelegate.parseWSDL(WSServiceDelegate.java:254) at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:217) at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:165) at com.sun.xml.internal.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:93) at javax.xml.ws.Service.<init>(Service.java:56) at com.globalsight.www.webservices.WebService4AEM_Service.<init>(WebService4AEM_Service.java:43) at com.adobe.cq.CustomerServiceImpl.insertGlobalsightData(CustomerServiceImpl.java:103) at org.apache.jsp.apps.jcrpersist.components.page.templateJCR.persist_json_jsp._jspService(persist_json_jsp.java:159) at org.apache.sling.scripting.jsp.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
BTW, but if i make that to invoke in a single class file that have a main function, the problem is ok.
public static void main(String[] args) { .... URL wsdlURL = new URL(strURL.toString()); WebService4AEM_Service ss = null; ss = new WebService4AEM_Service(wsdlURL, SERVICE_NAME); WebService4AEM port = ss.getWebService4AEMPort(); java.lang.String _login_arg0 = username; java.lang.String _login_arg1 = password; java.lang.String _login__return = port.login(_login_arg0, _login_arg1); .... }
Also i find a way and try to solve that problem as following for increase time-out time, but can't find cxf-rt-frontend-jaxws.jar(contains class ClientProxy and others) this file existed in the Adobe repository https://repo.adobe.com/nexus/content/groups/public/org/apache/cxf/.
Client cl = ClientProxy.getClient(servicePort); HTTPConduit http = (HTTPConduit) cl.getConduit(); HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy(); httpClientPolicy.setConnectionTimeout(10000); httpClientPolicy.setReceiveTimeout(1000); http.setClient(httpClientPolicy);
Anyone know how to resolve this problem? Keep waiting reply onlines.
Thanks a lot in advance.
Brian