In node-soap, how can I see / debug the generated XML SOAP request?

I am trying to use the node-soap module as follows:

const soap = require('soap');

soap.createClient('some-wsdl-url', function(err, client) {
    const args = {
        'ValidateCustomerRequest': {
            'memberNumber': 12345
        }
    };

    client.ValidateCustomer(args, function(err, result) {
        console.log(result);
    });
});

Now I get an "invalid format" response from the web service. To debug this, I would really like to see what the actual XML that is sent to the webservice looks like.

I already tried this one:

require('request').debug = true

... what was suggested in another SO answer .

But the result is not so useful:

[ERROR] REQUEST { uri:
  Url { ... },
  method: 'GET',
  headers:
   { 'User-Agent': 'node-soap/0.18.0',
     Accept: 'text/html,application/xhtml+xml,application/xml,text/xml;q=0.9,*/*;q=0.8',
     'Accept-Encoding': 'none',
     'Accept-Charset': 'utf-8',
     Connection: 'close',
     Host: 'xxx' },
  followAllRedirects: true,
  body: null,
  callback: [Function] }

I do not see my "ValidateCustomerRequest" there, and the body is null. I also wonder why the GET method should not be POST?

So, does this debug output look normal and / or is there another way to see the generated XML request?

+4
source share
1 answer

:

. lastRequest - ,

webservice. , :

const soap = require('soap');

soap.createClient('some-wsdl-url', function(err, client) {
    const args = {
        'ValidateCustomerRequest': {
            'memberNumber': 12345
        }
    };

    client.ValidateCustomer(args, function(err, result) {
        console.log(result);
        console.log('last request: ', client.lastRequest) // <-- here
    });
});

XML.

+8

Source: https://habr.com/ru/post/1669184/


All Articles