在 SoapUI 模拟服务响应脚本中,我需要使用请求中的值
在 SoapUI 模拟服务响应脚本中,我需要使用请求中的值。我试图让 value_2 在响应中使用它。
例如,SOAPUI 模拟服务收到以下请求:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="urn:company:test">
<SOAP-ENV:Body>
<ns1:field_1 xmlns="urn:company:test">
<field_2>
<field_3>value_1</field_3>
</field_2>
<field_4>
<field_5>
<field_6>value_2</field_6>
</field_5>
</field_4>
<field_4>
<field_5>
<field_6>value_3</field_6>
</field_5>
</field_4>
</ns1:field_1>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
我访问了以下链接,但它对我不起作用。
访问 SOAP UI 模拟响应中的请求 XML script
我还尝试了以下几行但失败了。
def req = new XmlSlurper().parseText(mockRequest.requestContent)
context.theValue = req.field_1.field_4.field_5.field_6
另请注意,我使用的是基础版(不是专业版),
您能帮我解决这个问题吗?
谢谢,托尼
In a SoapUI mock service response script i need to use a value from a request. I am trying to get value_2 to use it in the response.
e.g. SOAPUI mock service receives the following request:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="urn:company:test">
<SOAP-ENV:Body>
<ns1:field_1 xmlns="urn:company:test">
<field_2>
<field_3>value_1</field_3>
</field_2>
<field_4>
<field_5>
<field_6>value_2</field_6>
</field_5>
</field_4>
<field_4>
<field_5>
<field_6>value_3</field_6>
</field_5>
</field_4>
</ns1:field_1>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
I have visited the following links, but it did not work for me.
Access the request XML in a SOAP UI mock response script
SoapUI getting request parameters in mock service script
Also I tried following lines and failed.
def req = new XmlSlurper().parseText(mockRequest.requestContent)
context.theValue = req.field_1.field_4.field_5.field_6
Also please note that I use Basic Version (not Pro)
Could you please help me to resolve this issue?
Thanks, Tony
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你可以尝试一下:
应该打印出来吗
Can you try:
That should print out