问题描述
下面是我用来从excel工作表中获取数据并在我的请求中使用的代码。
import jxl.*
def TestCase = context.testCase
def FilePath = "D:\\DataSheet_Services_create.xls"
def count
Workbook WorkBook1 = Workbook.getWorkbook(new File(FilePath))
Sheet getExcelSheet = WorkBook1.getSheet("SearchCustomer")
PropertiesTestStep = TestCase.getTestStepByName("Properties")
count = PropertiesTestStep.getPropertyValue("Counter").toInteger()
读取Excel数据:
Cell Field20 = getExcelSheet.getCell(19,count)
Cell Field21 = getExcelSheet.getCell(20,count)
将单元格值设置为属性:
PropertiesTestStep.setPropertyValue("propertyName1",Field19.getContents())
PropertiesTestStep.setPropertyValue("propertyValue1",Field20.getContents())
我的请求:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<ws:companyId>?</ws:companyId>
</soapenv:Header>
<soapenv:Body>
<ws:createCustomer>
<ws1:customerDTO>
<properties>
<propertyName>${Properties#propertyName1}</propertyName>
<propertyValue>${Properties#propertyValue1}</propertyValue>
</properties>
</ws1:customerDTO>
</ws:createCustomer>
</soapenv:Body>
</soapenv:Envelope>
我的实际问题:在excel数据中,没有N个properties参数,在这种情况下,如何像下面这样在请求xml中动态插入properties节点
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<ws:companyId>?</ws:companyId>
</soapenv:Header>
<soapenv:Body>
<ws:createCustomer>
<ws1:customerDTO>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<ws:companyId>?</ws:companyId>
</soapenv:Header>
<soapenv:Body>
<ws:createCustomer>
<ws1:customerDTO>
<properties>
<propertyName>${Properties#propertyName1}</propertyName>
<propertyValue>${Properties#propertyValue1}</propertyValue>
</properties>
<properties>
<propertyName>${Properties#propertyName2}</propertyName>
<propertyValue>${Properties#propertyValue2}</propertyValue>
</properties>
<properties>
<propertyName>${Properties#propertyName3}</propertyName>
<propertyValue>${Properties#propertyValue3}</propertyValue>
</properties>
</ws1:customerDTO>
</ws:createCustomer>
</soapenv:Body>
</soapenv:Envelope>
</ws1:customerDTO>
</ws:createCustomer>
</soapenv:Body>
</soapenv:Envelope>
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)