Consuming RESTful web service via proxy server

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
Kazunori Kasahara
Posts: 15
Joined: Wed May 25, 2016 5:26 pm

Consuming RESTful web service via proxy server

Post by Kazunori Kasahara » Fri Aug 07, 2020 5:05 pm

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.

AmitS
Posts: 3
Joined: Mon Jul 20, 2020 6:49 pm

Re: Consuming RESTful web service via proxy server

Post by AmitS » Thu Feb 11, 2021 9:09 am

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!

User avatar
Dino
Posts: 124
Joined: Fri Jul 19, 2019 7:49 am
Location: Robbinsville, NC
Contact:

Re: Consuming RESTful web service via proxy server

Post by Dino » Fri Feb 12, 2021 1:11 am

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)

AmitS
Posts: 3
Joined: Mon Jul 20, 2020 6:49 pm

Re: Consuming RESTful web service via proxy server

Post by AmitS » Wed Feb 17, 2021 4:51 am

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!

AmitS
Posts: 3
Joined: Mon Jul 20, 2020 6:49 pm

Re: Consuming RESTful web service via proxy server

Post by AmitS » Thu Mar 11, 2021 10:49 am

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!

Post Reply