开发者

In a SoapUI mock service response script i need to use a value from a request

开发者 https://www.devze.com 2023-02-02 06:27 出处:网络
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.

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>
       开发者_如何学JAVA        <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


Can you try:

println req.Body.field_1.field_4*.field_5.field_6

That should print out

[value_2, value_3]
0

精彩评论

暂无评论...
验证码 换一张
取 消