How to fix invoke CXF webService connection timeout | Community
Skip to main content
October 16, 2015
Solved

How to fix invoke CXF webService connection timeout

  • October 16, 2015
  • 5 replies
  • 4388 views

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by smacdonald2008

We have an article that shows how to successfully build an AEM web service OSGi bundle using CFX:

https://helpx.adobe.com/experience-manager/using/creating-cxf-bundles-consume-web.html

(you may know about this one - but for other communty members looking for this informtion -- see the above link). 

When you build the proxy Java classes using CXF - the tool generates these classes (using the sample WSDL in the article)

[img]proxyclasses.png[/img]

We used these default classes and they work perfectly.

Now for configuring these classes to change default values - ie - timeout value, etc - you will hvae to look on the CFX web site - that is not related to AEM. Start researching that here:

http://cxf.apache.org/

Hope this helps. 

5 replies

October 16, 2015

It helpful a lot.  Thanks for your comments.

smacdonald2008
Level 10
October 16, 2015

Looks like you are trying to make an AJAX call to an AEM servlet. That should be straightforward - as shown here:

https://helpx.adobe.com/experience-manager/using/custom-sling-servlets.html

no need to encode URL for it to work - see the above code - you can deploy the package and see it work. 

October 16, 2015

hi scott,

I check the associated log in the AEM,  find the reason why time out is :  user type  the parameter  login-password is .m4c*Int3l+     but as a result  request.getParameter("password") that get value ignored the symbol "+".

var url = location.pathname.replace(".html", "/_jcr_content.persist.json") + "?hostName="+ hostName +"&hostPort="+ hostPort +"&username="+ username +"&password=" + password + "&enableHttps="+ enableHttps +"&desc="+desc +"&checkInterval=" +checkInterval; $.ajax(url, { dataType: "text", success: function(rawData, status, xhr) { var data;

I  don't know why happened that?  If should to need encode url  and decode url?   please comment on it.

October 16, 2015

Hi Scott,

 

The problem happened as well.   But i find the solution is following:

var data = $("password").val(); data = data.replace(/\+/g, "%2B");
smacdonald2008
smacdonald2008Accepted solution
Level 10
October 16, 2015

We have an article that shows how to successfully build an AEM web service OSGi bundle using CFX:

https://helpx.adobe.com/experience-manager/using/creating-cxf-bundles-consume-web.html

(you may know about this one - but for other communty members looking for this informtion -- see the above link). 

When you build the proxy Java classes using CXF - the tool generates these classes (using the sample WSDL in the article)

[img]proxyclasses.png[/img]

We used these default classes and they work perfectly.

Now for configuring these classes to change default values - ie - timeout value, etc - you will hvae to look on the CFX web site - that is not related to AEM. Start researching that here:

http://cxf.apache.org/

Hope this helps.