'Node soap, issue with the namespace

We are using soap package to make the SOAP based requests. However, we have an issue where the targetNameSpace is included in the request body as an attribute.

For example, it adds <tns:SendTestMessage xmlns="http://tempuri.org/"> xmlns to the tag.

What I need is <tns:SendTestMessage>

Below is the code that is used

    import * as soap from 'soap';
    var options = {
      ignoredNamespaces: {
        namespaces: ['targetNamespace'],
        override: true,
      },
    };

    soap.createClient("wsdl_url", options, (err, client) => {
      client.addHttpHeader('SOAPAction', 'soap action here goes here');

      client.SendTestMessage(body, (error, response) => {
        console.log(response?.config?.data);
        if (error) {
          console.error(error);
        } else {
          console.log(response);
        }
      });
    });
  }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source