0

When I initiate a soap request, I receive a phone number with prefix 91 (eg. 919876543210) as a response.

I want to use this number as an input value in other request through transfer property but without the prefix 91 (eg. 9876543210).Please help in finding how to do so.

I am using free version SoapUI.

Rao
  • 20,781
  • 11
  • 57
  • 77
Nexus5 Siingh
  • 11
  • 1
  • 4
  • Can you show your sample response? – Rao Dec 13 '17 at 06:16
  • 1
    my JDBC request is a select query and in response i receive this '919716499807'. the phone number captured from here will be used as input variable in other soap request , but without the prefix 91 – Nexus5 Siingh Dec 13 '17 at 06:27
  • Please check the solution to see if that helps and mark it [answered](https://stackoverflow/tour) if the issue resolves. – Rao Dec 13 '17 at 12:04
  • Nexus5, Have you got chance to try the solution? – Rao Dec 19 '17 at 00:32
  • HI Rao, I did try the solution and with some modification in the scripts given by you, achieved the required result through groovy Script. Thanks you so much for the help. The entire script i used is mentioned below. – Nexus5 Siingh Dec 27 '17 at 06:09
  • appreciate if you can mark it as [answered](https://stackoverflow.com/tour) – Rao Dec 27 '17 at 10:07

2 Answers2

1

You do not have to use Property Transfer step.

Instead, add Script Assertion for first request test step with following code and what that does is :

  • extracts isdn number from response
  • trims unwanted value
  • sets it at test case level
  • in the next request use the above stored value using Property Expansion
//Check if there is response
assert context.response

//Parse response and extract isdn value
def isdn = new XmlSlurper().parseText(context.response).'**'.find {it.name() == 'MSISDN'}.text()

//Trim first 2 digits and store at test case level
context.testCase.setPropertyValue('MSISDN', isdn.substring(2, isdn.size()))

In the send request, where the 10 digit number is needed, use as <elementname>${#TestCase#MSISDN}</elementname>

Actual value will be replaced when the 2nd request is sent.

Rao
  • 20,781
  • 11
  • 57
  • 77
0
//Check if there is response
//assert context.response

def input = context.expand('${MSISDN}')

Response = testRunner.testCase.testSteps["Copy of JDBC Request"].testRequest.response.contentAsString

//Parse response and extract isdn value

def isdn = new XmlSlurper().parseText(Response).'**'.find {it.name() == 'MSISDN'}.text()

//Trim first 2 digits and store at test case level

context.setProperty('MSISDN', isdn.substring(2, isdn.size()))

log.info isdn.substring(2, isdn.size())

Nexus5 Siingh
  • 11
  • 1
  • 4