esstokes1
Enthusiast
Enthusiast

XML parsing

I'm using vCO 5.1 and trying to parse XML using E4X.  An example of the XML string is included below.  The script appears to parse fine but it is ending with the following error: "Unable to serialize object of class : org.mozilla.javascript.xml.imp.xmlbeans.XMLList".  I put Sytem.log("FINISHED") on the last line of the script which is getting printed to the log file so I'm lost as to how to get past this error.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<ns3:provisionEnvironmentRequest majorVersion="1" minorVersion="0" xmlns:ns2="ht tp://local.com/cds/cloud" xmlns:ns4="http://local.com/csr/common" xmlns:ns3="http://local.com/CloudOps" xmlns:ns5="http://local.com/alps " xmlns:ns6="http://local.com/xmlns/cloud/metadataservice">

  <ns3:machine infrastructureContractKey="1-18" referenceArchitecture="rhel5" hostname="a0013225">

    <ns3:customTag name="puppetServer" value="puppetmaster.local.com"/>

     <ns3:customTag name="puppetCaServer" value="puppetca.local.com "/>

     <ns3:customTag name="mcollectiveServer" value="mco-rabbit.local.com"/>

  </ns3:machine>

  <ns3:machine infrastructureContractKey="1-18" referenceArchitecture="rhel5" hostname="a0013226">

     <ns3:customTag name="puppetServer" value="puppetmaster.localcom"/>

     <ns3:customTag name="puppetCaServer" value="puppetca.local.com "/>

     <ns3:customTag name="mcollectiveServer" value="mco-rabbit.local.com"/>

  </ns3:machine>

  <ns3:requestDateTime>2013-04-15T14:25:13.528Z</ns3:requestDateTime>

  <ns3:empId>123456</ns3:empId>

  <ns3:deploymentLevelCategory>idea farm</ns3:deploymentLevelCategory>

</ns3:provisionEnvironmentRequest>

It has something to do with parsing the XML and then setting the values from the XML to a variable that is an array of composite type.  Any help would be greatly appreciated.

Eric

0 Kudos
2 Replies
esstokes1
Enthusiast
Enthusiast

In case anyone else runs into something like this - I added .toString() to cast them to strings before adding them to the composite array and that seems to be working.

0 Kudos
tschoergez
Leadership
Leadership

Thanks for posting the solution!

Indeed a variable representing an XML-object in Javascript cannot be bound to a string parameter in the workflow (no matter if it's part of a composite or not) The value (meaning the xml string) is just not transfered to the parameter.

With the .toString() it really becomes a string object, and everything is fine.

Cheers,

Joerg

0 Kudos