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-12-2013 06:28 PM
Hello,
I believe that is possible. Take a look at the following link:
Invoking External Web Services
Thanks!
Mark Didrikson
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2013 01:32 AM
OK, that is good stuff when you want to whip up something from scratch, but is it possible to add parameters to a function defined in an existing SOAP message definition? For example, assume I have a SOAP Message called "test" pre defined on the system using System Web Services -> SOAP Message:
var s = new SOAPMessage('test', 'getTest');
s.setParameter('category', 'set1');
var response = s.post();
If we use something like:
var s = new SOAPMessage('test', 'getTest');
s.setParameter('category', 'set1');
s.setParameter('category', 'set2');
s.addFunctionParameter('extraparam', '123');
var response = s.post();
Obviously it will only set the 'category' parameter to be "set2", because there is only one parameter to set, but adding new ones seems to have no effect at all on the message going out.
Is there any way of adding extra parameters to a predefined message (i.e. without building it from scratch every time, but only adding the extra stuff, whilst setting the existing parameters)?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2013 06:38 AM
To add a function, I think you need to call set the function first using setFunctionName. See the link below:
http://wiki.servicenow.com/index.php?title=Web_Service_Consumer_Support#Creating_a_function_within_a_body_element
If I am following what you are asking for, you could try creating a script include.
http://wiki.servicenow.com/index.php?title=Script_Includes
Hope this helps!
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2013 06:22 AM
Sorry, my request is probably a bit off, but in short what I want to do is pass in an array of values to a SOAP Request, the same as can be done with most other platforms that allow you to interact with a web service.
I don't understand how best to achieve this on an existing SOAP Message definition in ServiceNow without directly manipulating the SOAPMessage object, creating a brand new request or editing an XMLDocument object.