jeudi 22 novembre 2018

How to manipulate xml file's variable in Karate DSL?

There are very limited numbered examples for SOAP services with Karate DSL.

What am I trying to do is, creating an XML file which I am going to use it later as template. Since it is going to be a template, I need to make some parts of it dynamic. It is easy to make it on .json files, but I couldn't find an example to make it happen for .xml files.

Let's sasy below one is my .xml file:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.bigldap.ttech.com/">
<soapenv:Header/>
<soapenv:Body>
    <ws:createwMsisdn>
        <name></name>
        <password>1</password>
        <appId>1</appId>
    </ws:createwMsisdn>
</soapenv:Body>

I want to convert name part to dynamic variable.

I've tried .replace and .set methods of Karate, but it didn't work.

* def user = read ('classpath:xxx/assign-name-password.xml')
* replace user.name = anotheruser.username
* print user

When print works, it shows only tags to me, as empty tags. () I couldn't find any related example.

Any help will be greatly appreciated. Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire