segadson
Contributor
Contributor

Process SOAP response and use those values as variables

Jump to solution

Hello,

I have a SOAP Request that I am trying to get the out parameters as variables but every time I run the workflow it is successful but I am not able to assign the out variables as parameters (but if I assign the parameter and do a system.log it works but it doesn't work if I want to use the result as a variable for another part of the workflow)

Here is the Output:

[2015-04-30 14:31:30.437] [I] processing response...

[2015-04-30 14:31:30.437] [I] out headers...

[2015-04-30 14:31:30.468] [I] out parameters...

[2015-04-30 14:31:30.475] [I] out parameters available:

[2015-04-30 14:31:30.476] [I]   + parameter name: 'GetRequestStatusResult', value: '<Response>

  <OutputParameters>

    <ServiceRequestID>SR145208</ServiceRequestID>

    <ServiceRequestStatus>DEPLOYING OS</ServiceRequestStatus>

    <ServiceRequestCreated>4/20/2015 5:57:59 PM</ServiceRequestCreated>

    <ServiceRequestCompleted></ServiceRequestCompleted>

    <CurrentActivity>MA145212</CurrentActivity>

    <CurrentActivityTitle>DEPLOYING OS</CurrentActivityTitle>

    <ActivityStartUTC></ActivityStartUTC>

    <ActivityEndUTC></ActivityEndUTC>

    <DurationTotalSeconds></DurationTotalSeconds>

    <AverageDurationSeconds></AverageDurationSeconds>

    <SecondsOffAverage></SecondsOffAverage>

    <EstimatedCompletionUTC></EstimatedCompletionUTC>

  </OutputParameters>

  <Warnings></Warnings>

  <Exceptions></Exceptions>

</Response>'

[2015-04-30 14:31:30.478] [I]   + parameter attribute name: '.(xmlns)', value: 'http://SystemCenter.JPMChase.net/'

Here is my scriptable task:

var getRequestStatusResult = outParameters.get("GetRequestStatusResult");

var content = getRequestStatusResult; // the XML text value of GetRequestStatusResult parameter above ( '<Response> ...  </Response>' ) 

var doc = new XML(content); // parse the whole response

serviceRequestNumber = doc.OutputParameters.ServiceRequestID;

Service_RequestStatus = doc.OutputParameters.ServiceRequestStatus;

serviceRequestCreated = doc.OutputParameters.ServiceRequestCreated;

serviceRequestCompleted = doc.OutputParameters.ServiceRequestCompleted;

currentActivity = doc.OutputParameters.CurrentActivity;

currentActivityTitle = doc.OutputParameters.CurrentActivityTitle;

activityStartUTC = doc.OutputParameters.ActivityStartUTC;

activityEndUTC = doc.OutputParameters.ActivityEndUTC;

durationTotalSeconds = doc.OutputParameters.DurationTotalSeconds;

averageDurationSeconds = doc.OutputParameters.AverageDurationSeconds;

secondsOffAverage = doc.OutputParameters.SecondsOffAverage;

estimatedCompletionUTC = doc.OutputParameters.EstimatedCompletionUTC;

0 Kudos
1 Solution

Accepted Solutions
tschoergez
Leadership
Leadership

not completely sure on that, but I think if you extract parts of an XML object, the result also is an XML object (and not a string).

If you want to bind the values to String attributes in your workflow, you have to explicitly convert them to strings, using the .toString() method.

So (out of mind, not tested!), this should do the job:

serviceRequestNumber = doc.OutputParameters.ServiceRequestID;

serviceRequestNumber = serviceRequestNumber.toString();

Service_RequestStatus = doc.OutputParameters.ServiceRequestStatus;

Service_RequestStatus = Service_RequestStatus.toString();

Using System.log automatically does the conversion, but only internally to create the log message. So you see the output, even if the allocation to the workflow attribute does not work.

Regards,

Joerg

www.vcoportal.de - Orchestrate. Your Cloud.

View solution in original post

0 Kudos
3 Replies
tschoergez
Leadership
Leadership

not completely sure on that, but I think if you extract parts of an XML object, the result also is an XML object (and not a string).

If you want to bind the values to String attributes in your workflow, you have to explicitly convert them to strings, using the .toString() method.

So (out of mind, not tested!), this should do the job:

serviceRequestNumber = doc.OutputParameters.ServiceRequestID;

serviceRequestNumber = serviceRequestNumber.toString();

Service_RequestStatus = doc.OutputParameters.ServiceRequestStatus;

Service_RequestStatus = Service_RequestStatus.toString();

Using System.log automatically does the conversion, but only internally to create the log message. So you see the output, even if the allocation to the workflow attribute does not work.

Regards,

Joerg

www.vcoportal.de - Orchestrate. Your Cloud.

View solution in original post

0 Kudos
segadson
Contributor
Contributor

THANK YOU!!!! AHHH I learned something new today! thanks!

0 Kudos
tschoergez
Leadership
Leadership

Glad that it worked!

That's indeed a tricky one, because you don't see errors (well, perhaps they are in server.log, if you configure debug log level, not sure though).

www.vcoportal.de - Orchestrate. Your Cloud.
0 Kudos