将变量传输到TestStep SOAPUI
我试图使用groovy脚本创建一个变量,然后在后续步骤中将其传输到SOAP请求 这是我的groovy脚本-TestStepInputVariables:将变量传输到TestStep SOAPUI,soap,groovy,soapui,Soap,Groovy,Soapui,我试图使用groovy脚本创建一个变量,然后在后续步骤中将其传输到SOAP请求 这是我的groovy脚本-TestStepInputVariables: def nextStep = testRunner.testCase.getTestStepByName("Add") def first = 88 def second = 12 def res = nextStep.run(testRunner, context) log.info res 然后在SOAP步骤(TestStepAdd
def nextStep = testRunner.testCase.getTestStepByName("Add")
def first = 88
def second = 12
def res = nextStep.run(testRunner, context)
log.info res
然后在SOAP步骤(TestStepAdd)中,我尝试以这种方式使用变量(如建议的):
“${#InputVariables#first}”
“${#输入变量#秒}”
但它不起作用。这是我收到的答复:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<soap:Fault>
<faultcode>soap:Client</faultcode>
<faultstring>System.Web.Services.Protocols.SoapException: Server was unable to read request. ---> System.InvalidOperationException: There is an error in XML document (5, 33). ---> System.FormatException: Input string was not in a correct format.
at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
at System.Xml.XmlConvert.ToInt32(String s)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read1_Add()
at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer.Deserialize(XmlSerializationReader reader)
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
--- End of inner exception stack trace ---
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle)
at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()
--- End of inner exception stack trace ---
at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()
at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()</faultstring>
<detail/>
</soap:Fault>
</soap:Body>
</soap:Envelope>
soap:客户端
System.Web.Services.Protocols.SoapException:服务器无法读取请求。-->System.InvalidOperationException:XML文档(5,33)中存在错误。-->System.FormatException:输入字符串的格式不正确。
位于System.Number.StringToNumber(字符串str、NumberStyles选项、NumberBuffer&;Number、NumberFormatInfo信息、布尔解析十进制)
在System.Number.ParseInt32(字符串s、NumberStyles样式、NumberFormatInfo信息)
位于System.Xml.XmlConvert.ToInt32(字符串s)
在Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read1_Add()中
在Microsoft.Xml.Serialization.GenerateAssembly.ArrayOfObjectSerializer.Deserialize(XmlSerializationReader)中
在System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader XmlReader,字符串编码样式,XmlDeserializationEvents)
---内部异常堆栈跟踪的结束---
在System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader XmlReader,字符串编码样式,XmlDeserializationEvents)
反序列化(XmlReader XmlReader,字符串编码样式)
在System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()中
---内部异常堆栈跟踪的结束---
在System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()中
在System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()中
我不知道我到底做错了什么。有人能帮忙吗?解决方案与链接问题略有不同。我这样修改了脚本:
def nextStep = testRunner.testCase.getTestStepByName("Add")
Integer first = 88
Integer second = 12
context.first = first
context.second = second
def res = nextStep.run(testRunner, context)
log.info res
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
<soapenv:Header/>
<soapenv:Body>
<tem:Add>
<tem:intA>${first}</tem:intA>
<tem:intB>${second}</tem:intB>
</tem:Add>
</soapenv:Body>
</soapenv:Envelope>
然后按如下方式执行添加步骤:
def nextStep = testRunner.testCase.getTestStepByName("Add")
Integer first = 88
Integer second = 12
context.first = first
context.second = second
def res = nextStep.run(testRunner, context)
log.info res
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
<soapenv:Header/>
<soapenv:Body>
<tem:Add>
<tem:intA>${first}</tem:intA>
<tem:intB>${second}</tem:intB>
</tem:Add>
</soapenv:Body>
</soapenv:Envelope>
${first}
${second}
就这些。我收到的回复没有错误:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<AddResponse xmlns="http://tempuri.org/">
<AddResult>100</AddResult>
</AddResponse>
</soap:Body>
</soap:Envelope>
100
解决方案与链接问题略有不同。我这样修改了脚本:
def nextStep = testRunner.testCase.getTestStepByName("Add")
Integer first = 88
Integer second = 12
context.first = first
context.second = second
def res = nextStep.run(testRunner, context)
log.info res
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
<soapenv:Header/>
<soapenv:Body>
<tem:Add>
<tem:intA>${first}</tem:intA>
<tem:intB>${second}</tem:intB>
</tem:Add>
</soapenv:Body>
</soapenv:Envelope>
然后按如下方式执行添加步骤:
def nextStep = testRunner.testCase.getTestStepByName("Add")
Integer first = 88
Integer second = 12
context.first = first
context.second = second
def res = nextStep.run(testRunner, context)
log.info res
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
<soapenv:Header/>
<soapenv:Body>
<tem:Add>
<tem:intA>${first}</tem:intA>
<tem:intB>${second}</tem:intB>
</tem:Add>
</soapenv:Body>
</soapenv:Envelope>
${first}
${second}
就这些。我收到的回复没有错误:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<AddResponse xmlns="http://tempuri.org/">
<AddResult>100</AddResult>
</AddResponse>
</soap:Body>
</soap:Envelope>
100
不知道,但是你有没有试过把从${InputVariables#first}
和${InputVariables#second}
中删除?@tim#yates是的,我试过这个主意,但你有没有试过把${code>从${InputVariables#first}和${InputVariables}
?@tim_-yates是的,我已经试过了