Property transfer in SOAPUI using groovy script

旧街凉风 提交于 2019-12-13 02:35:17

问题


Hi i am new to soapui and have this situation.I have two service memberservice1 where the response has "Region" property.I need to check this property and see if its value is "SCR" i need to modify it to "SCA" and pass it to another WS memberservice2.

I tried this way but couldnt get it.Can anyone please suggest.

def smlholder = groovyUtils.getXMLholder("Webservice#request");
def node = smlholder.getnodevalue("//region");

if(node  == 'SCA')
    testRunner.testcase.testSteps("anotherwebservicename").setProperty('Region','SCR');

回答1:


Your example code does not match you statement. Below I will follow your statement, and ignore the broken code example.

There are several different ways this cane be done. The easiest would probably be:

def region = context.expand("${Webservice#Response#//*:region}")
if (region == "SCR")
       testRunner.testCase.testSteps["anotherwebservicename"].setProperty("Region", "SCA");
else
       testRunner.testCase.testSteps["anotherwebservicename"].setProperty("Region", region);


来源:https://stackoverflow.com/questions/31192398/property-transfer-in-soapui-using-groovy-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!