Node soap client create XML with multiple values for same attribute

416
February 10, 2017, at 03:04 AM

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?

Answer 1

I ended up building a string and passing that for the client input.

var xmlString = '<customerId xmlns="http...">'+request.customerId+'</customerId>'
request.mdn.map(function (mdnValue) {
    xmlString += '<mdn xmlns="http...">'+mdnValue+'</mdn>'; 
});
var xmlObject = {$xml: xmlString};
return resolve(xmlObject);

Anyone know a more best-practice type approach?

Rent Charter Buses Company
READ ALSO
Cannot connect to a Node.js/Socket.io/Express server externally

Cannot connect to a Node.js/Socket.io/Express server externally

So I'm trying to connect to my server which I've created with Nodejs,Socket

433
Change file permissions in mutler using fs.chown

Change file permissions in mutler using fs.chown

How can I change file permissions using fschown in mutler storage

429
Node.js click button based on text

Node.js click button based on text

I have a test website with aa simply button (Click)I want to click the button using selenium-webdriver, I tried the following: driver

475
Having source code for third party javascript libraries available whilst debugging in IntelliJ

Having source code for third party javascript libraries available whilst debugging in IntelliJ

I would like to know whether it is possible to have third-party javascript libraries' source code available whilst debugging in IntelliJ - as one can already do when working on a java codebase

305