Body from template
By using a Freemarker template we can have more dynamic body content.
Don't send a second argument element: error
The Freemarker template will not send a arg2 element if no value is supplied (the whole element will be omitted, as can be seen in the request below). The service will not like this.
Omitting the element on a null value could not be done when the body was in the scenario content.
script | xml http test | |||
template | samplePost.ftl.xml | |||
set value | http://tempuri.org/SOAP.Demo.AddInteger | for header | SOAPAction | |
set value | 10 | for | arg1 | |
note | the following 'post' is prefixed with 'reject' as the fixture will return false when a soap fault is returned | |||
reject | post template to | http://www.crcind.com/csp/samples/SOAP.Demo.cls | ||
check | response status | 400 | ||
show | request | <s11:Envelope xmlns:s11="http://schemas.xmlsoap.org/soap/envelope/"> <s11:Body/> </s11:Envelope> | ||
show | response | Bad Request |
Send a second argument element: success
When a second argument value is set the enclosing element is sent by the Freemarker template (as visible in the shown request content below), and the SOAP call will succeed.
script | xml http test | |||||||||||||||||||||
template | samplePost.ftl.xml | |||||||||||||||||||||
set value | http://tempuri.org/SOAP.Demo.AddInteger | for header | SOAPAction | |||||||||||||||||||
set value | 10 | for | arg1 | |||||||||||||||||||
set value | 30 | for | arg2 | |||||||||||||||||||
post template to | http://www.crcind.com/csp/samples/SOAP.Demo.cls | |||||||||||||||||||||
check | response status | 200 | ||||||||||||||||||||
show | request | <s11:Envelope xmlns:s11="http://schemas.xmlsoap.org/soap/envelope/"> <s11:Body> <ns1:AddInteger xmlns:ns1="http://tempuri.org"> <ns1:Arg1>10</ns1:Arg1> <ns1:Arg2>30</ns1:Arg2> </ns1:AddInteger> </s11:Body> </s11:Envelope> | ||||||||||||||||||||
show | response headers |
| ||||||||||||||||||||
show | response | <?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:s="http://www.w3.org/2001/XMLSchema"> <SOAP-ENV:Body> <AddIntegerResponse xmlns="http://tempuri.org"> <AddIntegerResult>40</AddIntegerResult> </AddIntegerResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope> | ||||||||||||||||||||
register prefix | tempuri | for namespace | http://tempuri.org | |||||||||||||||||||
check | xPath | //tempuri:AddIntegerResult/text() | 40 |