Check Out the Latest News About SmartBear Connect
JOIN OUR WEEKLY CHALLENGE
API_Bloom_banner

API Bloom is a weekly prize-winning challenge in the Ready! API Community. Each week, we assign a task that you need to accomplish to become a winner. See the rules here.

THIS WEEK TASK
Give the biggest number of Solutions on the Ready! API forums
Top 3 contributors will get $50, $35, and $15 gift cards!

WEEK 1-12 WINNERS
@nmrao, @msiadak, @Debz, @richie, @Emil91, @PramodYadav, @jkrier, @sanj, @mbheeke, @Radford, @kmaster, @kbw

Reply
New Contributor
Posts: 2
Registered: ‎08-11-2017

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.

Highlighted
Contributor
Posts: 54
Registered: ‎12-29-2015

Re: soap request doesn't replace variable

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 . 

New Contributor
Posts: 2
Registered: ‎08-11-2017

Re: soap request doesn't replace variable

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?

Contributor
Posts: 54
Registered: ‎12-29-2015

Re: soap request doesn't replace variable

[ Edited ]

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. 

Frequent Contributor
Posts: 93
Registered: ‎12-06-2016

Re: soap request doesn't replace variable

More info about the context variable 

https://www.soapui.org/scripting---properties/the-soapui-object-model.html

 

Can you set a property value from the list then use that property in a request?

context.testCase.setPropertyValue( "MyProp", context.get('msisdnList').last() ) 

 

 

 

Let's Meet in Boston
Join the user conference on Sep 12-13