Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
EspenH
Partner - Contributor III
Partner - Contributor III

How to insert a context variable into a XML file in thttpClient and field RequestBody?

I have a thttpClient which i use to request a SOAP service.

In this component I have a Request Body formated as Text with the necessary escape characters:

"<?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>
<GetTransactions xmlns=\"http://24sevenoffice.com/webservices/economy/accounting/\">
<searchParams>
<DateSearchParameters>EntryDate</DateSearchParameters>
<ShowOpenEntries>1</ShowOpenEntries>
<DateStart>2025-01-01</DateStart>
<DateEnd>2025-01-02</DateEnd>
<TransactionTypeId>15</TransactionTypeId>
</searchParams>
</GetTransactions>
</soap12:Body>
</soap12:Envelope>"

This request works, but i would like to use context variables in the elements/tags DateStart and DateEnd.

I have set the variables in a tJavaRow component formated as string, but I have trouble to set the variables into the XML?

Do any of you experts out there know how to do this?

Labels (3)
4 Replies
Denis_Segard
Support
Support

See an example here :

Denis_Segard_0-1751262146033.png

 

EspenH
Partner - Contributor III
Partner - Contributor III
Author

Hi Denis_Segard, its not possible to see in the picture you attached, its to grainy if I zoome in... Please post a new picture or write the code to use....

Denis_Segard
Support
Support

Hello,

Code used in "Body" content :

"<?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>
<GetTransactions xmlns=\"http://24sevenoffice.com/webservices/economy/accounting/\">
<searchParams>
<DateSearchParameters>EntryDate</DateSearchParameters>
<ShowOpenEntries>1</ShowOpenEntries>
<DateStart>"+context.DateStart+"</DateStart>
<DateEnd>"+context.DateEnd+"</DateEnd>
<TransactionTypeId>15</TransactionTypeId>
</searchParams>
</GetTransactions>
</soap12:Body>
</soap12:Envelope>"

 

Kind regards
Denis

EspenH
Partner - Contributor III
Partner - Contributor III
Author

Hi Denis_Segard

I have tried this code before, but then i get an error.

EspenH_0-1751343889159.png

On the other hand if I use escape character in this code like:

<DateStart>\"+context.DateStart+\"</DateStart>
<DateEnd>\"+context.DateEnd+\"</DateEnd>

I do not get an error, but also no result. Somhow the dates are then not red propper dates... 

I have found a workaround and create the whole xml part in tjava, put it in an context variable and use this variable in the Request body, but would still like to hav a solution where i could only insert the dates as context variables in the XML...