Forum Discussion

canpan14's avatar
canpan14
Occasional Contributor
10 years ago

Transferring entire XML response using property transfer?

I'm currently calling a database and trying to move the reponse to a property using property transfer. The response comes in a nice xml form but when I try and use property transfer the property is just filled with blank. If I just do it only a single field it works fine, but doing it on the whole reponse doesn't work. I checked the 'Transfer Child Nodes' box but that didn't help either.

 

Any ideas, or other ways to go about this that would be better?

  • nmrao's avatar
    nmrao
    10 years ago

    You may in the following fashion(exiting property transfer will become obselete in this case)

     

    1. Have the following script as part of script assertion to the jdbc request step, so that the response of the jdbc step would be saved into a given property, so that it can be used where it is needed later.
    def response = messageExchange.responseContent
    assert null != response, "Response does not have any value"
    //provide appropriate name for property below
    def response = context.testCase.setPropertyValue('PROPERTY_NAME', response)

    Later, you may get the property value in  order to use like

     

    - context.expand('${#TestCase#PROPERTRY_NAME}')

    - context.testCase.getPropertyValue('PROPERTY_NAME')

    • canpan14's avatar
      canpan14
      Occasional Contributor

      Sure thing. I'm basically pulling a table in a db (it just has one row and a number of columns).

       

      So I get an xml like this:

       

      <Results>

         <ResultSet fetchSize="64">

            <Row rowNumber="1">

               <DataValue1>1</DataValue1>

               <DataValue2>2</DataValue2>

                                     ...

            </Row>

         </ResultSet>

      </Result>

       

      Then I'm pulling in another table from another db and check that they have the exact same content and format. I thought I could just save both results in seperate properties and assert that they need to be equal, but when I try and use property transfer to put the result in a property, it just shows up as [ ].                          

       

      • nmrao's avatar
        nmrao
        Champion Level 3

        You may in the following fashion(exiting property transfer will become obselete in this case)

         

        1. Have the following script as part of script assertion to the jdbc request step, so that the response of the jdbc step would be saved into a given property, so that it can be used where it is needed later.
        def response = messageExchange.responseContent
        assert null != response, "Response does not have any value"
        //provide appropriate name for property below
        def response = context.testCase.setPropertyValue('PROPERTY_NAME', response)

        Later, you may get the property value in  order to use like

         

        - context.expand('${#TestCase#PROPERTRY_NAME}')

        - context.testCase.getPropertyValue('PROPERTY_NAME')