Slowness in HttpClient
- How-to
- API
- HTTPClient
- POST
- REST
- Jorge Escobar
- PowerBuilder
- Saturday, 20 June 2020 12:39 AM UTC
I am consuming a REST API from PowerBuilder 2019 R2. For this I use the HttpClient class.
When running the API from Posman, Insomnia and SoapUI the response is immediate (thousandths of a second)
However, when I run it from PowerBuilder, at best it takes 10 seconds and many times over 60 seconds and the app freezes.
inv_httpClient.ClearRequestHeaders()
// Establecer propiedades en el Header
inv_HttpClient.SetRequestHeader("Content-Type", "application/json; charset=UTF-8")
inv_httpClient.setRequestHeader( "Authorization", "Bearer" + " " + is_accessToken)
inv_HttpClient.SetRequestHeader("Content-Length", String(ll_contentLength))
inv_httpClient.Timeout = 10
lt_begin = now()
// Ejecutar el request
li_rc = inv_httpClient.sendRequest( "POST",ls_URL,lblb_data)
lt_end = now()
IF li_rc <> 1 THEN
of_setMessage( of_getErrorHttp( li_rc ))
RETURN -1
END IF
The problem occurs when running from the sources and from the executable and I have even tried with PB 2017 R3.
As a test, I have created a WebService in Java from which I run the API and returns an XML that I collect via SOAP from PowerBuilder and with this the response improves considerably and the screen does not freeze. However, bringing this scenario to production implies having a Glassfish or Tomcat web server, deploying the service, etc. and it is not viable; so I have to look for a solution to slow when executing the HttpClient.sendRequest. If you have had a similar problem I will appreciate your recommendations.
Gracias
Find Questions by Tag
Helpful?
If a reply or comment is helpful for you, please don’t hesitate to click the Helpful button. This action is further confirmation of their invaluable contribution to the Appeon Community.