SOAP Message Complex Types: How do we send these using SOAPMessage()?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-12-2013 08:06 AM
What kind of support for complex types is there in a ServiceNow SOAPMessage? What is the best way of dynamically adding multiple elements into one when creating a SOAP message using a script?
By my understanding the "complexType" tag, when used in a WSDL, should allow the same thing to be entered into a request multiple times, for example, sending the following out as part of a SOAP request where the exampleElement is entered several times with different data:
<complexType>
<exampleElement>Data 1</exampleElement>
<exampleElement>Data 2</exampleElement>
<exampleElement>Data 3</exampleElement>
</complexType>
From what I can see, when a SOAP Message is created on the system, it only really lets you create one variable for the data and, once that is set using scripting, it does not allow you to create more elements within the complex type element:
<complexType>
<exampleElement>${variable_1}</exampleElement>
</complexType>
The generated code for this would come out something like:
var s = new SOAPMessage('demo', 'demoName');
s.setParameter('variable_1', 'example data');
var response = s.post();
I am not familiar enough with the SOAPMessage API to generate multiple examples of the same data item within a complex request (as in the first demonstration).
Is this possible?
- Labels:
-
Integrations

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2013 08:22 AM
Where is the array being created? Are you looping over the array and then populating the SOAP requests?
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2013 09:02 AM
From what I can see, every integration implementation builds SOAPEnvelopes from scratch without looking at an existing definition on the system (so they use SOAPMessage() instead of SOAPMessage('(SOAP Message Name)', '(Function Name)')).
Unfortunately the limitations placed on me mean that by my understanding we only want to add the data to pre defined messages without building entire messages from scratch.
So assume that the data is some kind of list or array coming from a script from which we will want to add new elements to the request as part of a complex type. Normally we would build this by making a Message and Envelope from scratch each time, but the limitations placed on me mean that building messages from scratch is not an option, and that we must use messages and functions pre defined on the SOAP Message table.
How can we call a pre existing SOAP Message Function from the sys_soap_message table in a script, which takes a complex type as input, such that we can add any number of elements of the same type but with differing values each time within it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2013 09:36 AM
Sorry, I'm overthinking things as usual, yes the idea is to loop over the array and populate the soap requests with data. (EDIT: Assume the array contains a number of random strings)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2013 03:08 PM
Check out the following blog post. This is how I add dynamic segments of XML into a SOAP request (such as with Array type of data):
http://www.john-james-andersen.com/blog/service-now/inserting-xml-into-servicenows-soapmessage-object.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2013 01:19 AM
Sorry for being verbose, I got a bit too focussed on the details of trying to get it to work in Servicenow.
I was kind of hoping that Servicenow would support this with some kind of out of the box function so that updating the SOAP Message would mean that we don't have to edit any scripts, but every single example I can find is pointing toward manually building parts of the message using scripts, so that is what we are going to have to do.
Thanks everyone!