VMware Cloud Community
schistad
Enthusiast
Enthusiast

Convert SOAP out parameters into real objects

While using SOAP to interact with our IPAM (Men and Mice), I find myself slightly frustrated by the fact that it returns nested object arrays which become flattened into simply a list of properties.

Is there any way of rehydrating these into actual Javascript objects?

For example, a simple list of IP ranges look like this:

+ parameter name: 'ranges.range[0].ref', value: '{#6-#553}'

+ parameter name: 'ranges.range[0].name', value: 'XX.YY.ZZ.0/24'

+ parameter name: 'ranges.range[0].from', value: 'XX.YY.ZZ.0'

+ parameter name: 'ranges.range[0].to', value: 'XX.YY.ZZ.255'

+ parameter name: 'ranges.range[0].parentRef', value: '{#6-#546}'

+ parameter name: 'ranges.range[0].childRanges', value: 'null'

+ parameter name: 'ranges.range[0].dhcpScopes', value: 'null'

+ parameter name: 'ranges.range[0].subnet', value: 'false'

+ parameter name: 'ranges.range[0].locked', value: 'false'

+ parameter name: 'ranges.range[0].inheritAccess', value: 'false'

+ parameter name: 'ranges.range[0].autoAssign', value: 'false'

+ parameter name: 'ranges.range[0].hasSchedule', value: 'false'

+ parameter name: 'ranges.range[0].hasMonitor', value: 'false'

+ parameter name: 'ranges.range[0].customProperties.property[0].name', value: 'Location'

+ parameter name: 'ranges.range[0].customProperties.property[0].value', value: 'Datacenter'

+ parameter name: 'ranges.range[0].customProperties.property[1].name', value: 'Title'

+ parameter name: 'ranges.range[0].customProperties.property[1].value', value: 'Dedicated iSCSI network 1'

+ parameter name: 'ranges.range[0].customProperties.property[2].name', value: 'vlan'

+ parameter name: 'ranges.range[0].customProperties.property[2].value', value: '5'

+ parameter name: 'ranges.range[0].isContainer', value: 'false'

+ parameter name: 'ranges.range[0].utilizationPercentage', value: '22'

+ parameter name: 'ranges.range[0].hasRogueAddresses', value: 'false'

+ parameter name: 'totalResults', value: '1'

+ parameter attribute name: '.(xmlns)', value: 'http://menandmice.com/webservices/'

To retrieve the range ref property from this response, I currently have to do something like:

rangeRef=outParameters["ranges.range[0].ref"]

Which is very inelegant once you need to retrieve a nested property on multiple objects.

I have a feeling that this list may in fact be deserializable through some standard method, but I am not experienced enough with JavaScript to know how...

0 Kudos
4 Replies
Burke-
VMware Employee
VMware Employee

I have not personally worked with this particular product using the SOAP api yet... however, it seems that VMware IT had done so a few years ago as per this Slideshare presentation from VMworld 2013:  VMworld 2013: Practicing What We Preach: VMware IT on vCenter Operati….

I have put in a request to see if I can get any of the code samples used there for the parsing. Will update here if I receive anything that can be sanitized and shared.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you!

Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator
for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter
schistad
Enthusiast
Enthusiast

Yeah I noticed that reference as well. If you are able to get any code out that would be great Smiley Happy

0 Kudos
cdecanini_
VMware Employee
VMware Employee

If you can get the XML instead of individual parameters then you may use the library xml2json action.

Once you have JSON in a variable getting the JavaScript object is as simple as doing var object = JSON.parse(jsonString);

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter
0 Kudos
schistad
Enthusiast
Enthusiast

Interesting.. Any way to get the raw XML through the SOAP plugin?

0 Kudos