Reputation: 103
I defined a variable with
* def token = '1bce02b8..'
I would like to retrieve the variable I defined so I can pass this to my SOAP request. How can I make this possible?
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.com">
<soapenv:Header/>
<soapenv:Body>
<ws:isValid>
<token>$token</token>
</ws:isValid>
</soapenv:Body>
</soapenv:Envelope>
Upvotes: 1
Views: 1678
Reputation: 58088
Easy, use embedded expressions in the #(foo)
form, they work for XML as well:
* def token = 'foo'
* def payload =
"""
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.com">
<soapenv:Header/>
<soapenv:Body>
<ws:isValid>
<token>#(token)</token>
</ws:isValid>
</soapenv:Body>
</soapenv:Envelope>
"""
* print payload
Which prints:
[print] <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.com">
<soapenv:Header/>
<soapenv:Body>
<ws:isValid>
<token>foo</token>
</ws:isValid>
</soapenv:Body>
</soapenv:Envelope>
I suggest you also refer to this set of examples, specifically for XML that will give you more ideas: xml.feature
Upvotes: 2