SOAP_TO_OBJECT
The function SOAP_TO_OBJECT takes a SOAP envelope in the form of a string and returns the equivalent Object in Airscript.
This function takes a string as input. The given string is expected to be parsable as a valid SOAP envelope. It returns the equivalent Object in Airscript.
This function is also capable of parsing modifiers that define formatting elements with no one-to-one equivalent in Airscript Objects. These modifiers make it possible to use the SOAP_TO_OBJECT function to generate Objects that incorporate the information stored in XML elements and attributes such that context is maintained. Modifier details must be specified in a single modifier Object that the SOAP_TO_OBJECT function accepts as optional input.
Declaration
Parameters
soap (required, type: string) A string that represents a valid SOAP envelope.
modifier (optional, type: Object) An object with one or many of the following properties:
ignoreAttributes (optional, type: boolean, default:
TRUE
) - Defines whether the resulting will exclude XML attributes when generating the equivalent Object.TRUE
means that it will,FALSE
means that it won't.attributeNamePrefix (optional, type: string, default:
""
) - Defines the string that will distinguish XML elements from XML attributes when the equivalent Object is generated. Object properties generated by XML elements will have the attributeNamePrefix prefixing their key, while Object properties generated by XML attributes will not.
Return Values
object (type: Object) The Airscript Object equivalent to the given SOAP envelope.
Examples
Assume the following examples has access to the following SOAP envelope, which has been pulled in from an external system and converted into a string designated example_soap
:
The string example_soap
can be given directly as input to the SOAP_TO_OBJECT function:
By default, the attributes of the example SOAP envelope are ignored when generating the equivalent Object, but this can be changed by using a modifier Object with an ignoreAttributes property, as follows:
The Object generated by the above expression does not differentiate which of its properties were generated from XML elements and which of its properties were generated from XML attributes. This can be changed by explicitly defining an attributeNamePrefix property in the modifier Object. For instance, in the following example, Object properties generated from XML elements are prefixed with the string "@"
, allowing the contextual difference between the XML elements and attributes to be maintained:
Last updated