HttpClientRequest as proxy

marting66652718

18-01-2018

Hey, I just built a get function that calls on a https API, but the server-department at my office wants me to use a proxy for this. Im relativily new to proxies, so my question is if anyone has an idea of how to wrap this get function in to a https proxy?

loadLibrary("cus:json3.js");

//Require temp Schema to match against city

var query = xtk.queryDef.create(

  <queryDef operation="select" schema={vars.targetSchema}>

    <select>

      <node expr="@smartcity"/>

    </select>

  </queryDef>

);

var res = query.ExecuteQuery();

function getCall(){

  var http = new HttpClientRequest();

  http.url = "https://url..." + line.@smartcity + "...restoftheurlandkey";

  http.method = "GET"; //The GET request

  http.execute();

  var response = http.response;

  logInfo( response.body.toString());

};

for each (var line in res) {

  getCall();

};

In regards, Martin!

Accepted Solutions (1)

Accepted Solutions (1)

Vapsy

Employee

24-01-2018

Hi Martin,

There is a setting in serverConf.xml and it is called as <proxyConfig> where you can define subnodes as <proxyHTTP> and <proxyHTTPS> wherein you can define the proxy address, credentials and the port details.

<proxyConfig enabled="true" override="localhost*" useSingleProxy="false">

     <!-- HTTP Proxy -->

     <proxyHTTP address="svr001.zone2.proxy.mynetwork" login="" password="" port="8080" />

     <!-- Secure proxy -->

     <proxyHTTPS address="svr001.zone2.proxy.mynetwork" login="" password="" port="8080" />

</proxyConfig>

However, as per my knowledge, there is a limitation at Campaign side that proxy is not used by activities like Web Download. Not sure if the impact is on JS code activity as well.

I'll suggest to get the proxy settings applied in the config, then restart the services.

Post that test your code. Another way is you can use the curl library to make a GET request from inside workflow. Test and see if it works.

Regards,
Vipul

Answers (4)

Answers (4)

florentlb

22-01-2018

Hi Martin,

This is far beyond my knowledge, so bumping this thread anyway.

Let me know if you manage to find something in the meantime.

Florent