3

I am using the node-soap module and it's working fine, except when I am working behind a proxy. I can't manage to find the way to set that proxy so I can request the API.

soap.createClient(url, function(err, client) {
      client.MyFunction(args, function(err, result) {
          console.log(result);
      });
});

It's written in the docs :

The options argument allows you to customize the client with the following properties:

request: to override the request module.
httpClient: to provide your own http client that implements request(rurl, data, callback, exheaders, exoptions).

Is that the way to go?

Wilfred Hughes
  • 29,846
  • 15
  • 139
  • 192
krakig
  • 1,515
  • 1
  • 19
  • 33

2 Answers2

14

In the soap.createClient() options set 'request' to a request object that has 'proxy' set using request.defaults().

let request = require('request');
let request_with_defaults = request.defaults({'proxy': PROXY_URL, 'timeout': 5000, 'connection': 'keep-alive'});
let soap_client_options = {'request': request_with_defaults};
soap.createClient(WSDL_URL, soap_client_options, function(err, client) {
abridges
  • 156
  • 1
  • 5
3

Well, after looking at the code, I found that you could just declare your proxy as an environment variable.

process.env.http_proxy = 'http://proxyhost:proxyport';

This works!

krakig
  • 1,515
  • 1
  • 19
  • 33