Outbound SOAP Message - need to dynamically generate the payload
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2016 07:38 AM
I have an integration with an in-house application that, up until now, has relied on sending single field values via a SOAP message. My new requirement is to send the contents of a list collector field. Each entry in the list collector references a record on another table with five values. Each of these values must be sent for each entry in the list collector. The web service in question has been updated and the SOAP Message Function from the new WSDL produces an envelope that contains the following block:
I need to dynamically generate my SOAP payload to contain as many copies of this block as there are entries in the list collector. Is there a way to accomplish this in ServiceNow or am I limited to the envelope as generated in the SOAP Message Function?
My fallback is to recursively collect all of these values into an array, pass that to the web service as a single value and then require them to parse the array.
Thanks in advance for your help.
Jon
- Labels:
-
Integrations
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2016 07:43 AM
Can you pull the values into an array, then do a for loop through the array, and then call the new SOAPMessage logic in the for loop, creating a separate SOAP call for each item?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2016 08:13 AM
Possibly - yes. It would require the webservice to add another function. This current function creates a new record in the in-house app so I'd need a function to update an existing record but that might work out.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2016 01:49 PM
One option is you can generate entire SOAP message and use setRequestBody API to set body of soap request instead of relying on soap envelop template.
SOAPMessageV2 API - ServiceNow Wiki
The other option i can think of is modify SOAP envelop template to parameterize entire list and populate list string by your self.
<productClassList>${listValue}</productClassList>
Now in you script, you can iterate over your array of items and create a XML structure with which you can create XML string and call
.setParameter(listValue, <yourXMLString>). This will replace ${listValue} with your string.