Forum Discussion

rprsekhar's avatar
rprsekhar
New Contributor
7 years ago

Reading Dynamic tags in response

I am using SOAP UI free version. I am beginner and working on a groovy script to read a excel, replace properties in a request file and run the request in a loop. For reading response, i gave xpahs and writing the data to a text file. This works fine for a pass scenario because of the xpath. For failed scenario, given xpath is not valid and comes with  different tags. So, i am looking to find a way to validate pass or fail or condition the xpath based on a particular tag.

Given xpath for reading data:

def tag1 =  responseXmlHolder["//b:tag1"]

def tag2 =  responseXmlHolder["//b:tag2"]

Sample Pass Response

Sample Failure Response

<s:Body u:Id="_2">

      <TagResponse xmlns="http://www. ">

         <TagResult xmlns:b="http://www. ">

            <b:tag1>Value1</b:tag1>

            <b:tag2>Value2</b:tag2>

         </ TagResult >

      </ TagResponse >

 </s:Body>

<s:Body u:Id="_2">

      <s:Fault>

         <s:Code>

            <s:Value>s:Sender</s:Value>

            <s:Subcode>

               <s:Value>s:READERR</s:Value>

            </s:Subcode>

         </s:Code>

         <s:Reason>

            <s:Text xml:lang="en-GB">Serialization Error</s:Text>

         </s:Reason>

         <s:Detail>

            <FaultDetails xmlns="http://www. " xmlns:i="http://www.w3.org/2001/XMLSchema-instance">

               <FaultDetail>

                  <Cause>Serialization Error</Cause>

                  <Code>READERR</Code>

                  <Description>There was an error</Description>

                  <FailingFieldName i:nil="true"/>

                  <Solution>Please change the value and try again</Solution>

                  <Source>Framework</Source>

               </FaultDetail>

            </FaultDetails>

         </s:Detail>

      </s:Fault>

   </s:Body>