As most messages will need to manage multiple data items, this tutorial will demonstration how to construct a SOAP 1.2 message type.
The template of the message header:
Host: www.w3schools.com
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
The template of the message body:
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<CelsiusToFahrenheit xmlns="http://tempuri.org/">
<Celsius>string</Celsius>
</CelsiusToFahrenheit>
</soap12:Body>
</soap12:Envelope>
Note: the placeholders "length" and "string" are hi-lighted in a different color.
To convert the two parts of the message, the majority of the text can be created using literals, however, the placeholders must be inserted using variables or functions.
As the message header contains the length of the body, we need to create this string first. We will be passing the Celsius parameter into the routine as a float variable type, fortunately, ESL automatically converts the float to string, so only the follow copy statement is required to build the message body:
copy "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n"
"<soap12:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\">\r\n"
" <soap12:Body>\r\n"
" <CelsiusToFahrenheit xmlns=\"http://tempuri.org/\">\r\n"
" <Celsius>"Celsius_FV"</Celsius>\r\n"
" </CelsiusToFahrenheit>\r\n"
" </soap12:Body>\r\n"
"</soap12:Envelope>" to Body_SV
Having created the message body string, the header is similar to create, this time using the built-in function "length of" to replace the length placeholder.
copy "Host: www.w3schools.com\r\n"
"Content-Type: application/soap+xml; charset=utf-8\r\n"
"Content-Length: " length of Body_SV "\r\n" to Header_SV
Note: the use of escape sequences to replace carriage returns (\r), new lines (\n) and double quotes (\").