Page 1 of 1
Consuming RESTful web service via proxy server
Posted: Fri Aug 07, 2020 5:05 pm
by Kazunori Kasahara
Our customer would like to consume RESTful web service via Proxy server using XPRIM_HttpRequest from VL Server Module.
They need to through the proxy server with basic access authentication to perform HTTP request from their network.
They need to do the following steps when calling web service URL using browser address bar:
1. Enter RESTful web service URL in browser.
2. Browser opens the authentication dialog prompting for username and password of proxy server.
3. Enter user and password for proxy authentication.
4. RESTful web service is consumed and returns JSON.
They added the http_proxy and https_proxy Windows environment variables (They are executing VL Web application using IIS on Windows).
e.g. http_proxy http://user:
password@proxy.domain.com:port
But they couldn't do HTTP request from VL Server Module. XPRIM_HttpRequest returned the WinHttpSendRequest 12002 error meaning time out.
Does anyone have any experience of doing HTTP request via proxy server from VL Server Module?
Any advice would be appreciated.
Thank you.
Re: Consuming RESTful web service via proxy server
Posted: Thu Feb 11, 2021 9:09 am
by AmitS
Hello,
We are also facing a very similar challenge. Does anyone know how this can be solved?
Any help is very much appreciated. Thank you!
Re: Consuming RESTful web service via proxy server
Posted: Fri Feb 12, 2021 1:11 am
by Dino
There is one example using basicaauthentication to connect to Twilio in the reusable part XWS_SMS_Provider_Twilio . But I am not sure if this kind of authentication is the same as the proxy authentication you are referring. Is that just a popup window with 2 authentication fields?
Code: Select all
* Construct Request
#UrlBuilder.SetScheme( 'https' )
#UrlBuilder.SetHost( 'api.twilio.com' )
#UrlBuilder.SetPath( '/2010-04-01/Accounts/' )
#UrlBuilder.AddPathComponent( #AccountSID )
#UrlBuilder.AddPathComponent( 'Messages.json' )
*
#COM_SELF.InitializeHttpRequest Httprequest(#Request)
#Request.Content.AddUrlEncodedFormValue Name('Body') Value(#BodyText)
#Request.Content.AddUrlEncodedFormValue Name('From') Value(#Sender)
#Request.Content.AddUrlEncodedFormValue Name('To') Value(#Message.Recipient)
#Request.Options.AddBasicAuthorization Username(#AccountSID) Password(#AuthToken)
#Request.DoPost Url(#UrlBuilder)
#COM_SELF.GetResponseFromHttpRequest Httpresponse(#Request.Response) Status(#Status) Loglabel(SendSMS)
Re: Consuming RESTful web service via proxy server
Posted: Wed Feb 17, 2021 4:51 am
by AmitS
Thank you Dino for your response.
We have tried using the URIBuilder but it does not work for our case.
We are trying to implement below:
Define_Com Class(#XPRIM_HttpRequest) Name(#Req)
#Req.Content.AddUrlEncodedFormValue Name('grant_type') Value('client_credentials')
#Req.Content.AddUrlEncodedFormValue Name('client_id') Value('**')
#Req.Content.AddUrlEncodedFormValue Name('client_secret') Value('**')
#Req.DoPost Url(<token-URL>)
When we run this from a server with no proxy, it gives us result instantly, Request status returns as TRUE
But when executing same from VDI, which has proxy server, the request wait for 30 seconds and status is FALSE with error message : CONNECTION_ERROR WinHttpRequest: 12002: The operation timed out
We are trying to see how we can embed proxy-server in the HttpRequest but no luck yet.
Hope someone has found way around. Thank you in advance!
Re: Consuming RESTful web service via proxy server
Posted: Thu Mar 11, 2021 10:49 am
by AmitS
Hello All,
Just an update: We did not find any solution to this issue within LANSA. However, we managed to deliver this functionality by allowing these request to pass the firewall. Ideal situation would have been that httprequest enables us to specify which proxy to be used. Thanks!
Re: Consuming RESTful web service via proxy server
Posted: Wed Oct 29, 2025 8:26 pm
by Gilamonster
Hello All,
Facing a similar issue, when doing
#Request.DoPost Url(#UrlBuilder) from an IBM i to an external API server when a Proxy is needed.
The request wait for 30 seconds then a CONNECTION_ERROR status is FALSE with error message :
Failed to send outgoing data to the server, AxisTransportException : Cannot open a channel to the remote end. Failed to open connection to the server at host xxxxxxxxxxxxxxxx/oauth2/access_token Error is 3447 - A remote host did not respond within the timeout period;
I was able to replicate a similar error when doing a CURL from IBM i to the remote host without proxy.
But no more timeout error when I indicates the Proxy server to use and I am able to establish HTTP proxy tunnel to host xxxxxxxxxxx
> curl
http://proxy.myproxy.local:3128 -v
https://xxxxxxxxxxxxxxxxx/oauth2/acces_token
Would like to know if someone has found a solution to indicate a Proxy server when doing a request (XPRIM_HttpRequest) ?
I have triyed using #Req.Options.SetMiscProperty with values 'http_proxy' '
http://proxy.myproxy.local:3128' but without success
Any advices and idea will be welcome
Many thanks
Christophe