Forum Discussion

Tom_Arn's avatar
Tom_Arn
Contributor
17 years ago

Array response as input for further test steps

We want to create a TestCase where the response of one Test Step is used as input for the next step. The response contains an array of unknown size. The next step should use the response array as new input array.

We have succeeded in making this work for specifically defined elements of the response array by using a Property Transfer like this:
Source:

declare namespace m='http://www.tierverkehr.ch/XMLServicesOer/TVDOerXml';
//m:rinderTierverzeichnisResponse/tvXmlRinderTierverzeichnisStructHolder/rinder/TVXmlRindVO[1]/identitaet

Target:

declare namespace arrayType='java.com.csc.tvd.oerxml.vo.bestellwesen';
declare namespace tvd='http://www.tierverkehr.ch/XMLServicesOer/TVDOerXML';
//tvd:plausiRinderpass/tVXmlRinderpassStructHolder/rinderpass/item/arrayType:identitaet


How should this be defined, if we want to do this for all elements of the response array?

We tried something like

//m:rinderTierverzeichnisResponse/tvXmlRinderTierverzeichnisStructHolder/rinder/TVXmlRindVO[]/identitaet
but this did not work.

Thanks in advance
Tom

9 Replies

  • omatzura's avatar
    omatzura
    Super Contributor
    Hi Tom,

    could you either attach or mail me the full response and target request so I can play around with this locally to get it working?

    regards!

    /Ole
    eviware.com
  • omatzura's avatar
    omatzura
    Super Contributor
    Thanks!

    Exactly what do you want to transfer to the target? The entire contents of the rinder arrary (ie all 35 TVXmlRindV0)? Or just certain elements/values of each? Maybe you could fabricate a desired result xml (1 item is enough ;-), so I can see?

    bes regards,

    /Ole
    eviware.com
  • Let me explain in more details what we try to do:

    The first Test step calls the operation "rinderTierverzeichnis" which returns (among other elements) the array "rinder".

    "rinder" is defined as follows:
    <rinder xsi:type="java1:ArrayOfTVXmlRindVO" soapenc:arrayType="java1:TVXmlRindVO[]" xsi:nil="true" xmlns:java1="java:com.csc.tvd.oerxml.vo.abfragen"/>


    and "TVXmlRindVO" is defined as:
             <xsd:complexType name="TVXmlRindVO">
                <xsd:sequence>
                  <xsd:element type="xsd:dateTime" name="abgang" minOccurs="1" nillable="true" maxOccurs="1"/>
                  <xsd:element type="xsd:integer" name="farbe" minOccurs="1" nillable="true" maxOccurs="1"/>
                  <xsd:element type="xsd:dateTime" name="geburtsdatum" minOccurs="1" nillable="true" maxOccurs="1"/>
                  <xsd:element type="xsd:string" name="gesamtbefund" minOccurs="1" nillable="true" maxOccurs="1"/>
                  <xsd:element type="xsd:string" name="geschlecht" minOccurs="1" nillable="true" maxOccurs="1"/>
                  <xsd:element type="xsd:string" name="identitaet" minOccurs="1" nillable="true" maxOccurs="1"/>
                  <xsd:element type="xsd:string" name="rasse" minOccurs="1" nillable="true" maxOccurs="1"/>
                  <xsd:element type="xsd:string" name="tiername" minOccurs="1" nillable="true" maxOccurs="1"/>
                  <xsd:element type="xsd:dateTime" name="zugang" minOccurs="1" nillable="true" maxOccurs="1"/>
                </xsd:sequence>
            </xsd:complexType>


    We now want to call the operation plausiRinderpass which has (among other input elements) as input the array "rinderpass".  For this, all returned "identitaet" from "rinder" should be transferred to "indentitaet" in "rinderpass"

    "rinderpass" is defined as follows:
    <rinderpass xsi:type="java1:ArrayOfTVXmlRinderpassVO" soapenc:arrayType="java1:TVXmlRinderpassVO[]" xsi:nil="true" xmlns:java1="java:com.csc.tvd.oerxml.vo.bestellwesen"/>



    and TVXmlRinderpassVO is defined as:
             <xsd:complexType name="TVXmlRinderpassVO">
                <xsd:sequence>
                  <xsd:element type="xsd:string" name="errorCodes" minOccurs="1" nillable="true" maxOccurs="1"/>
                  <xsd:element type="xsd:string" name="identitaet" minOccurs="1" nillable="true" maxOccurs="1"/>
                  <xsd:element type="xsd:decimal" name="passnummer" minOccurs="1" nillable="true" maxOccurs="1"/>
                  <xsd:element type="xsd:string" name="warningCodes" minOccurs="1" nillable="true" maxOccurs="1"/>
                </xsd:sequence>
            </xsd:complexType>


    Tom
  • omatzura's avatar
    omatzura
    Super Contributor
    Thanks for the clarification Tom.. I'll see how I can get this working (the new XQuery property-transfer feature will hopefully come in handy..)

    best regards,

    /Ole
    eviware.com
  • omatzura's avatar
    omatzura
    Super Contributor
    Hi Tom,

    ok.. please try the following;

    Create a property-transfer-step containing a property-transfer that uses XQuery (checkbox bottom right in the latest snapshot), set the source step/property to your request and its response and set the source xquery expression to

    <rinderpass xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
    xsi:type="java1:ArrayOfTVXmlRinderpassVO" soapenc:arrayType="java1:TVXmlRinderpassVO[]"
    xsi:nil="true" xmlns:java1="java:com.csc.tvd.oerxml.vo.bestellwesen">
    {
        for $z in //identitaet/text()
                return <item xsi:type="arrayType:TVXmlRinderpassVO" xmlns:arrayType="java:com.csc.tvd.oerxml.vo.bestellwesen">
                          <arrayType:identitaet>{data($z)}</arrayType:identitaet></item>
    }
    </rinderpass>


    and the target teststep/request xpath to

    declare namespace tvd='http://www.tierverkehr.ch/XMLServicesOer/TVDOerXml';
    //tvd:plausiRinderpass/tVXmlRinderpassStructHolder/rinderpass


    I think the data gets transfered correctly, but you'll need to validate with your services for me..

    let me know!

    regards,

    /Ole
    eviware.com
  • That sounds great!
    But we'll probably need the latest snapshot 29.08.07, right?

    Since the next snapshot is around the corner, we'll wait for this and report back then.

    Thanks a lot!
    Tom
  • omatzura's avatar
    omatzura
    Super Contributor
    ok.. I'll let you know when the snapshot is available..

    regards,

    /Ole
    eviware.com
  • Hello Ole

    We tested the Test Case with SNAPSHOT 2007-09-10 and it works great!

    Thanks a lot!
    Tom

    P.S. Also the new Overview tab is very handy.