Web services 如何为多个值运行web服务
我试图在soapUI中运行一个设置了多个值的SOAPWeb服务,但未能实现。问题是如何为web服务的给定变量ID设置多个值,并为每个值获得相同的多个结果。 wsdl文件如下所示:Web services 如何为多个值运行web服务,web-services,groovy,soapui,Web Services,Groovy,Soapui,我试图在soapUI中运行一个设置了多个值的SOAPWeb服务,但未能实现。问题是如何为web服务的给定变量ID设置多个值,并为每个值获得相同的多个结果。 wsdl文件如下所示: <soapenv:Body> <ws:getData> <ws:reportID>MY_DATA</ws:reportID> <ws:key> <xsd:type>ID</xsd:type&
<soapenv:Body>
<ws:getData>
<ws:reportID>MY_DATA</ws:reportID>
<ws:key>
<xsd:type>ID</xsd:type>
<xsd:value>8456321</xsd:value>
</ws:key>
<ws:dateInfo>
<xsd:endDate>2016-05-24</xsd:endDate>
<xsd:startDate>2016-05-30</xsd:startDate>
</ws:dateInfo>
</ws:getData>
根据讨论,这属于数据驱动测试 虽然数据驱动测试特性是由ReadyAPI(soapui的付费版本)提供的,但在groovy脚本的帮助下,这也可以在免费版本中完成 对于您的案例,使用以下步骤创建测试案例:
- groovy脚本测试步骤(下面建议的脚本)
- soap请求测试步骤(您已在问题中显示)
//Provide the path of your data file below
def datasource = 'C:/Temp/data.csv'
//Read all the lines
def lines = new File(datasource).readLines()
lines.eachWithIndex { line, index ->
//Get the data
def data = line.toString().trim()
log.info "current data : $data"
//Set the current row data into context variable called type
context.type = data
//Fire the webservice except last row of the data file as last row is execute automatically
if (lines.size()-1 != index) {
step = context.testCase.testStepList[context.currentStepIndex+1]
step.run(testRunner, context)
} else {
log.info 'last record'
}
}
log.info 'going to finish'
在第2个测试步骤的soap请求中进行以下更改
更改为:
<ws:key>
<xsd:type>ID</xsd:type>
<xsd:value>8456321</xsd:value>
</ws:key>
多个值
-您的意思是reportID,键入
?如果是,您如何获得这些数据?通过文件?否则,请澄清。是的,我在一个文件中有所有这些ID,我想在soap接口中传递它们。使用循环或其他脚本?文件中的数据看起来如何?它是csv文件吗?类似于您的数据的虚拟数据将有助于理解。顺便问一下,数据是否有列名?是的,从excel文件导出。或者,我如何通过循环传递10个值来实现这一点?csv文件是否有列名?请提供样品数据?
<ws:key>
<xsd:type>ID</xsd:type>
<xsd:value>8456321</xsd:value>
</ws:key>
<ws:key>
<xsd:type>ID</xsd:type>
<xsd:value>${type}</xsd:value>
</ws:key>