1

I am using Karate to validate xml responses from two Webmethods. We have an old webmethod that directly hits a data source. We are adding a layer above that datasource with a Webmethod and database to return the same data. The expectation is the old webmethod and new webmethod will return the same data. What I am stuck on is the responses are showing in a different formats, one is JSON and the other is XML.

My feature file setup.

    Feature: Campare

  Background:
    * configure ssl = true
    * def ddaAccounts = read(<list of test accounts>)
    * configure printEnabled = false

  Scenario Outline: Compare responses
    Given url '<Old webmethod>'
    Given request read('<request body>')
    When method post
    Then status 200
    * xml hogan = response
    * xml hogan = $response /Envelope/Body/AcctTrnInqRs
    Given url '<new webmethod>'
    Given request read('<request body>')
    When method post
    Then status 200
    * xml oracle = response
    * xml oracle = $response /Envelope/Body/AcctTrnInqRs
    * match oracle == hogan

    Examples:
      | ddaAccounts |

The one thing we've notice is the one response that is returning as JSON has multiple account fields where the XML version has one.

Could that be causing the difference in formatting? Can this behavior be corrected?

Any thoughts/ help would be greatly appreciated.

Thank you, Joe

Joe
  • 743
  • 5
  • 10
  • 26

1 Answers1

0

responses are showing in a different formats

Depending on how you print, you may see JSON and error logs may show JSON even though it is XML. Please read: https://github.com/intuit/karate#print

For comparing 2 payloads where the data may be of different "shape" see https://stackoverflow.com/a/54241440/143475

Also see this answer for handling XML repeated elements - if you are trying to convert to JSON: https://stackoverflow.com/a/54241440/143475

Otherwise your question has insufficient data.

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248