node.jsxmlsoapnode-soap

node soap remove xmlns attribute from method


I'm using the npm soap package to work with a soap webservice.

Apparently it's the most widely used soap client in the Node.JS ecosystem, and I'm working with a fairly mature commercial webservice, so I don't know who's "wrong" (or non standard compliant), but I have an issue with xmlns attribute in the xml tag of the method I'm calling.

We generate requests like this:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:tns="https://webservice.com"
    xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/">
    <soap:Body>
        <MethodName xmlns="https://webservice.com">
        .......
        </MethodName>
    </soap:Body>
</soap:Envelope>

But the server rejects this, because it's expecting just <MethodName> and not <MethodName xmlns="...">. How can I remove this attribute from the request ? Ideally through options passed to the client, but I'm also open to using another soap client.

I can also use a plain http client and build xml manually, but I'm looking for a higher-level alternative if possible.


Solution

  • Apparently, strong-soap is a rewrite or at least has a similar API so soap and although it has less monthly downloads, it has a stronger community (judging by activity on their respective support/community chats) and it doesn't inject the xmlns attribute in the method tag.

    So if anyone else is stuck with soap, give strong-soap a try !