Mid server and Web services through proxy

hectormurolanuz
Mega Contributor

Hi!

In one of the integrations we are currently working on, we have the following structure:

        The target environment can be accessed and queried through rest (we just do 'gets' here)

        To access the target environment, we need to go through a proxy.

        Due to security restrictions, we are not allowed to install a mid server inside the target environment (and.. in this case, no is no).

Playing around with the platform, we are trying to identify how would we 'pass' that proxy, we end up dealing with the construction of a httpClient object to raise the getmethod from there, but unfortunately, we couldn't find any documentation on how to add the proxy credentials and the proxy set up to build the header correctly.

Somehow, the structure to build the request without the proxy is the following one:

    var GetMethod = Packages.org.apache.commons.httpclient.methods.GetMethod;  

      var GlideHTTPCient = Packages.com.glide.communications.HTTPClient;  

      var httpClient = new GlideHTTPCient();

      var getMethod = new GetMethod(this.setRestEndPoint());

      var httpStatus = httpClient.executeMethod(getMethod);  

      var response = getMethod.getResponseBodyAsString();  

      getMethod.releaseConnection();  

      var responseHeaders = getMethod.getResponseHeaders();

      var status = getMethod.getStatusCode();

     

      return (response);

Any idea/suggestion on how to

  1st add the proxy to the http header

  2nd add the credentials to authenticate in the proxy

6 REPLIES 6

tim_broberg
ServiceNow Employee
ServiceNow Employee

This is totally not my area, but...


  1. There is a GlideScriptable method setupProxy(String host, String port)
  2. The default proxy creds are accessible as parameters glide.http.proxy_username and glide.http.proxy_password.


Hope that's at least somewhat helpful.


    - Tim.


Azad2
Tera Contributor

The workaround to enable proxy support in Jakarta is as follows:

Find the file agent\conf\wrapper-override.conf under the directory where the MID server was installed.
Add the following parameters at the end of the file after substituting the right values for proxyHost and proxyPort:

wrapper.java.additional.1=-Dhttp.proxySet=true
wrapper.java.additional.2=-Dhttp.proxyHost=<proxyHost>
wrapper.java.additional.3=-Dhttp.proxyPort=<proxyPort>
wrapper.java.additional.4=-DuseProxy=true

Restart the MID to enable these properties