Search code examples
node.jsxmlsoapsoap-client

Node soap client create XML with multiple values for same attribute


I'm running into an issue with Node soap I feel should be common but I'm not finding anything in the docs or searches.

The XML I'm trying to generate has 4 parameters:

< customerId xmlns="http...">156668500< /customerId>
< mdn xmlns="http...">6204462197< /mdn>
< mdn xmlns="http...">6204462198< /mdn>
< mdn xmlns="http...">6204462199< /mdn>

Since the soap client only takes a JSON object (not sure about this part but I didn't find a way to pass raw XML and that wouldn't be an optimal solution anyway) I can't just pass the same attribute name (mdn) 3 times. I tried passing it as an array but that wraps each mdn in its own separate tag. Is there a best practice out there for accomplishing this?


Solution

  • I came across this issue recently and found that this is actually supported through arrays.

    {
      customerId: 156668500,
      mdn: [
        6204462197,
        6204462198,
        6204462198
      ]
    }