Soapui下拉列表未按预期工作

Soapui下拉列表未按预期工作,soap,drop-down-menu,groovy,dialog,soapui,Soap,Drop Down Menu,Groovy,Dialog,Soapui,使用Soapui处理Soap响应 这将把单个问题拉到一个对话框中。。很好 def ui = com.eviware.soapui.support.UISupport; groovyUtils = new com.eviware.soapui.support.GroovyUtils( context ); holder = groovyUtils.getXmlHolder("Question#Response"); holder.namespaces["ns1"] = "http://some.n

使用Soapui处理Soap响应

这将把单个问题拉到一个对话框中。。很好

def ui = com.eviware.soapui.support.UISupport;
groovyUtils = new com.eviware.soapui.support.GroovyUtils( context );
holder = groovyUtils.getXmlHolder("Question#Response");
holder.namespaces["ns1"] = "http://some.namespace.com";
def responseId = holder.getNodeValue("//ns1:questionText");
ui.showInfoMessage( responseId,"Question being asked" );
使用下拉模式,事情会变得有点有趣。 这是可行的,但只会在下拉列表中显示第一个问题和答案,并在每次单击时显示下拉列表。。我想显示问题标题和选项,换句话说,从SOAP的上一个响应中读取xml响应

def ui = com.eviware.soapui.support.UISupport;
groovyUtils = new com.eviware.soapui.support.GroovyUtils( context );
holder = groovyUtils.getXmlHolder("Question#Response");
holder.namespaces["ns2"] = "http://some.namespace.com";
for (responseId in holder["//ns2:text"])
//ui.showInfoMessage( responseId,"Question being asked" );
ui.prompt("Question being asked", "text", [responseId])
//result = com.eviware.soapui.support.UISupport.prompt("Question being asked", "Question", [responseId])
下面是示例SOAP-注意:我删除了head/tail,因为我主要关心的是提取问题和响应ID

          <ns1:callStatus>
             <ns1:statusCode>SUCCESS</ns1:statusCode>
             <ns1:statusDescription>Questions and answers retrieved successfully</ns1:statusDescription>
          </ns1:callStatus>
          <ns1:payload xsi:type="ns2:Response" xmlns:ns2="http://some.namespace.com">
             <ns2:questions>
                <ns2:questionId>AAA</ns2:questionId>
                <ns2:text>What is the color of your car?</ns2:text>
                <ns2:choices>
                   <ns2:choiceId>111</ns2:choiceId>
                   <ns2:text>Blue</ns2:text>
                </ns2:choices>
                <ns2:choices>
                   <ns2:choiceId>222</ns2:choiceId>
                   <ns2:text>Green</ns2:text>
                </ns2:choices>
                <ns2:choices>
                   <ns2:choiceId>333</ns2:choiceId>
                   <ns2:text>Black</ns2:text>
                </ns2:choices>
             </ns2:questions>
             <ns2:questions>
                <ns2:questionId>BBB</ns2:questionId>
                <ns2:text>What is the name of your dog?</ns2:text>
                <ns2:choices>
                   <ns2:choiceId>111</ns2:choiceId>
                   <ns2:text>Barney</ns2:text>
                </ns2:choices>
                <ns2:choices>
                   <ns2:choiceId>222</ns2:choiceId>
                   <ns2:text>Rover</ns2:text>
                </ns2:choices>
                <ns2:choices>
                   <ns2:choiceId>333</ns2:choiceId>
                   <ns2:text>Patches</ns2:text>
                </ns2:choices>
             </ns2:questions>
             <ns2:questions>
                <ns2:questionId>CCC</ns2:questionId>
                <ns2:text>What if the name of your spouse?</ns2:text>
                <ns2:choices>
                   <ns2:choiceId>111</ns2:choiceId>
                   <ns2:text>Latecia</ns2:text>
                </ns2:choices>
                <ns2:choices>
                   <ns2:choiceId>222</ns2:choiceId>
                   <ns2:text>Mary</ns2:text>
                </ns2:choices>
                <ns2:choices>
                   <ns2:choiceId>333</ns2:choiceId>
                   <ns2:text>Samantha</ns2:text>
                </ns2:choices>
             </ns2:questions>
          </ns1:payload>

成功
已成功检索问题和答案
AAA
你的车是什么颜色的?
111
蓝色
222
绿色
333
黑色
BBB
你的狗叫什么名字?
111
巴尼
222
罗孚
333
补丁
CCC
如果你的配偶的名字?
111
拉蒂西亚
222
玛丽
333
萨曼莎

我也遇到了同样的问题,并构建了此解决方案:

def ui = com.eviware.soapui.support.UISupport;

List<String> choice = new ArrayList<String>();
List<String> values = new ArrayList<String>();

/* Parse the XML to fill the lists in the following format.
   Something like:
     for (responseId in holder["//ns2:text"])
     {
        choice.add('${responseId.text} (${responseId.choiceId})')
        values.add( responseId.choiceId )
     }
*/
choice.add('label (value)') 
values.add('value')
/* Note: The 'value' in the choice list is optional but 
   should be used if you have duplicate labels. */

// Some example data:
choice.add('Red (#FF0000)')
values.add('#FF0000')
choice.add('Green (#00FF00)')
values.add('#FF0000')
choice.add('Blue (#0000FF)')
values.add('#FF0000')

// Ask the question
def result = ui.prompt("Question being asked", "text", choice, 'val')

// The answer
log.info result

// The position of the answer
log.info choice.indexOf(result)

// The associated value
log.info values.get( choice.indexOf(result) )
def ui=com.eviware.soapui.support.UISupport;
列表选项=新建ArrayList();
列表值=新的ArrayList();
/*解析XML以按以下格式填充列表。
比如:
for(holder[“//ns2:text”]中的responseId)
{
choice.add(${responseId.text}(${responseId.choiceId}))
values.add(responseId.choiceId)
}
*/
选项。添加('标签(值)')
value.add('value')
/*注意:选项列表中的“值”是可选的,但
如果有重复的标签,则应使用*/
//一些示例数据:
选项。添加('Red(#FF0000'))
值。添加(“#FF0000”)
选项。添加('Green(#00FF00'))
值。添加(“#FF0000”)
选择。添加('Blue(#0000FF)'))
值。添加(“#FF0000”)
//提问
def result=ui.prompt(“正在询问的问题”、“文本”、选项“val”)
//答案
log.info结果
//答案的位置
log.info choice.indexOf(结果)
//关联值
log.info values.get(choice.indexOf(result))
希望这对别人有帮助