Forum Discussion

mamar's avatar
mamar
Contributor
11 years ago

How to replace "?" with user input in soap request

Hi,
I have a requirement, which i need to replace all the "?" with the user input with Groovy code. Details are below. ( i am using soapui free version)

i have a request like below....

<soapenv:Envelope xmlns="http://www.ifxforum.org/IFX_150" xmlns:com.fnf="http://www.fnf.com/xes" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v2="http://www.fnf.com/xes/services/debit/debitadd/v2_0">
<soapenv:Header>
<soapenv:Body>
<CompositeCurAmt>
<CompositeCurAmtType>DEBIT_AMT</CompositeCurAmtType>
<CurAmt>
<Amt>53.00</Amt>
<CurCode>USD</CurCode>
</CurAmt>
</CompositeCurAmt>
<DepAcctId>
<AcctId>00002281092151</AcctId>
</DepAcctId>
<com.fnf:TellerAdditionalInfo>
<com.fnf:TrnSeqNum>9455</com.fnf:TrnSeqNum>
</com.fnf:TellerAdditionalInfo>
</soapenv:Body>
</soapenv:Envelope>

and i will be configuring in soapui test request like below.

<soapenv:Envelope xmlns="http://www.ifxforum.org/IFX_150" xmlns:com.fnf="http://www.fnf.com/xes" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v2="http://www.fnf.com/xes/services/debit/debitadd/v2_0">
<soapenv:Header>
<soapenv:Body>
<CompositeCurAmt>
<CompositeCurAmtType>DEBIT_AMT</CompositeCurAmtType>
<CurAmt>
<Amt>?</Amt> /* here i need to replace the "?" with amount 53.00 by taking from test case property through groovy code */
<CurCode>USD</CurCode>
</CurAmt>
</CompositeCurAmt>
<DepAcctId>
<AcctId>?</AcctId> /* here i need to replace the "?" with account 00002281092151 by taking from test case property through groovy code */
</DepAcctId>
<com.fnf:TellerAdditionalInfo>
<com.fnf:TrnSeqNum>?</com.fnf:TrnSeqNum> /* here i need to replace the "?" with seq number 9455 by taking from test case property through groovy code */
</com.fnf:TellerAdditionalInfo>
</soapenv:Body>
</soapenv:Envelope>

I have taken the inputs from the excel and placed in the test case property. the inputs Amt, AcctId, TrnSeqNum are also in the test case property. Now, when i run the test case, during the execution, i need to configure a groovy in such a way, first it needs to get the input request and replace all the "?"s with the respective input values from the test case property and then it should run. the same needs to be processed for all the test inputs from my excel.

can anyone help me on how to do it in groovy.

3 Replies

  • Thanks for the link. I am new to Java, Groovy...so i feel difficult with the code to understand (from the link.) Because it says about creating new nodes in the xml string. As i am new to development, i dono how to use it and modify for my requirement. So is there any easy way to just iterate through the nodes and search for the elements with "?" and replace the value from the soapui test case property?
  • mehersate's avatar
    mehersate
    New Contributor

    Did you ever find a way o get through this ?? am also in the exact same situation