Hello (vCO Beginner),
I am using the SOAP Plugin and trying to figure out how to handle the response from the a SOAP host Here is the Log that I am getting from the SOAP response
[2014-05-09 12:53:43.124] [I] out parameters...
[2014-05-09 12:53:43.135] [I] out parameters available:
[2014-05-09 12:53:43.136] [I] + parameter name: 'GetRequestStatusResult', value: '<Response>
<OutputParameters>
<ServiceRequestID>SR138917 </ServiceRequestID>
<ServiceRequestStatus>DEPLOYING OS</ServiceRequestStatus>
<ServiceRequestCreated>5/9/2014 3:20:25 PM</ServiceRequestCreated>
<ServiceRequestCompleted></ServiceRequestCompleted>
<CurrentActivity>MA138921</CurrentActivity>
<CurrentActivityTitle>DEPLOYING OS</CurrentActivityTitle>
<ActivityStartUTC>05/09/2014 15:32</ActivityStartUTC>
<ActivityEndUTC></ActivityEndUTC>
<DurationTotalSeconds></DurationTotalSeconds>
<AverageDurationSeconds></AverageDurationSeconds>
<SecondsOffAverage></SecondsOffAverage>
<EstimatedCompletionUTC></EstimatedCompletionUTC>
</OutputParameters>
<Warnings></Warnings>
<Exceptions></Exceptions>
</Response>'
Will it be best to try and just parse the text or try and use another method with vCO
If you haven't yet, take a look at the com.vmware.libarary.soap.processOutParameters action. It is the action that generated the log you have shown us. It generates a Properties object (key, value pairs) which has the value for each resulting parameter.
In your case, assuming "outProps" is the output of the action mentioned above, you can use:
var getRequestStatusResult = outProps.get("GetRequestStatusResult");
And parse the XML with E4X as Ilian has shown.
Hi,
Parsing it with E4X is pretty easy. For example, here is a snippet showing how to parse and fetch the value of 'ServiceRequestCreated' element:
var content = ...; // the XML text value of GetRequestStatusResult parameter above ( '<Response> ... </Response>' )
var doc = new XML(content); // parse the whole response
System.log(" service request created on -> " + doc.OutputParameters.ServiceRequestCreated);
If you haven't yet, take a look at the com.vmware.libarary.soap.processOutParameters action. It is the action that generated the log you have shown us. It generates a Properties object (key, value pairs) which has the value for each resulting parameter.
In your case, assuming "outProps" is the output of the action mentioned above, you can use:
var getRequestStatusResult = outProps.get("GetRequestStatusResult");
And parse the XML with E4X as Ilian has shown.
Hey I have a question. How come when i use that information I can log the correct information but i cant set that information as a variable so I can use it elsewhere in the workflow