2

I am using node-soap library to make some requests on my Nest app.

In order to create the client, I am using the following code:

const client = await soap.createClientAsync(requestURL, {
    wsdl_options: {
        timeout: 600000,
    },
});

client.addHttpHeader('Connection', 'Keep-Alive');
client.addHttpHeader('Accept-Encoding', 'gzip,deflate');

And, this one as an example of the request:

const providerResponse = await client.doAvailableProductsAsync(request);
return providerResponse[0]

This code is working fine when I remove the client.addHttpHeader('Accept-Encoding', 'gzip,deflate');, but with it, is throwing the following exception:

{
  faultcode: 500,
  faultstring: 'Invalid XML',
  detail: 'Error: Non-whitespace before first tag.\nLine: 0\nColumn: 1\nChar: \u001f',
  statusCode: 500
}

Furthermore, the exception shows an encoded text with special chars. I guess, the header is working fine, but my node-soap client is not able to decode the response properly from the server side.

Am I missing any soap-related configuration?
I read the docs carefully and I could not find any reference to request compression.

Thanks in advance.

Isaac Bosca
  • 1,588
  • 1
  • 15
  • 34

0 Answers0