Forum Discussion

itsika's avatar
itsika
Occasional Contributor
8 years ago

comparing two xml response

hi

i am shifting my svc service to different platform and i would like to test both services the original and the new one with same request and compare the response.

the response is not 100% identical i have element with execution time that i need to ignore.

 

also the response contain UTF-8 Characters, any suggestions for simple solution?

 

 

 

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Consider using either the Send Request keyword operation or the script equivalent.  It will send an HTTP request to the indicated service and retrieve the response.  That response can be stored in a variable.

     

    So, you could send a request to your old site, save the response, then send a request to the new site, save the response, and then compare the two responses.

    • itsika's avatar
      itsika
      Occasional Contributor

      thanks,

      my challenge is how to implement the compare between the two responses.

      • itsika's avatar
        itsika
        Occasional Contributor

        Problem Solved,

        i wrote a groovy script that remove elements

         

        //read Biztalk response
        def policy = context.expand( '${Get-Data....}' )
        def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
        def policyBT = groovyUtils.getXmlHolder( policy)

        //remove unCompare Elements
        policyBT.removeDomNodes("//RetrieveTime")
        policyBT.removeDomNodes("//RetrospectiveTime")

        //read DataPower response
        def policyD = context.expand( '${Get-Data....}' )
        def policyDP = groovyUtils.getXmlHolder( policyD)

        //remove unCompare Elements
        policyDP.removeDomNodes("//RetrieveTime")
        policyDP.removeDomNodes("//RetrospectiveTime")

        //export fixxed response XML value into TestCase properites  for comparing in the Next Step
        def policyBTstr = policyBT.prettyXml
        def policyDPstr = policyDP.prettyXml
        log.info policyDPstr
        testRunner.testCase.setPropertyValue('BT-h-response', policyBTstr)
        testRunner.testCase.setPropertyValue('DP-h-response',policyDPstr)

         

         

         

        After That I'm running an Assertion step with XPath Match.

         

         

        my only problem now is that in project suit i would expect Details but i see only:

        [Equals] Simple Equals  FAILED
        [XPath Match] XPath Match  FAILED