Forum Discussion

italkbb's avatar
italkbb
New Contributor
7 years ago

soap request doesn't replace variable

Hi, 

I'm trying to build a script that will open a file of phone numbers, 1 per line. It then reads in each line and add each line to an array. I add the array to the context.

 

def msisdnList = []
new File("C:\\Users\\Jerry\\Documents\\MVNO\\soapui\\msisdn_99.txt").eachLine { f ->
if (f != null ) {
     
     msisdnList.add(f)
     //log.info f
}
}
if (msisdnList.size() < 1) {
   testRunner.fail("No request msisdn")
}
context.put('msisdnList', msisdnList)

In the next step, i check i can read the array, which works fine:

log.info "MSISDN: ${context.get('msisdnList').last()}"

In the failing step, i try a soap request which (envelope and header skipped) like this:

     <ADD_SOC_REQUEST>
         <MSISDN>${context.get('msisdnList').last()}</MSISDN>
         <SOC>SMPGL2</SOC>
      </ADD_SOC_REQUEST>

running this, I get error because what goes out is 

 

<MSISDN></MSISDN>

Does substitution work in SOAP request?

 

Thanks.

4 Replies

  • Can you try one thing ?

     

    Inplace of putting all those directly in the Soap request.

     

    1-Just add a data generator before the Soap request.

    2-Add a Template in the data generator .

    3-Add this in the Template.

         <ADD_SOC_REQUEST>
             <MSISDN>${context.get('msisdnList').last()}</MSISDN>
             <SOC>SMPGL2</SOC>
          </ADD_SOC_REQUEST>

    4-Run the data generator .

    5-Now call & add the template key in the Soap request & run the step.

     

    Hope it will work . 

    • italkbb's avatar
      italkbb
      New Contributor

      I am looking for a SoapUI solution. As far as I can see, the data generator is part of SoapUI PRO. I don't have $599 to solve this problem! 

      Is this possible on SoapUI Open Source?

      • Pritish_Panda's avatar
        Pritish_Panda
        Contributor

        You don't have $599 to solve this problem! sorry to hear that .  I thought you are using PRO version . 

         

        You will get the solution soon by any expert.