Forum Discussion

Torsten_Mangner's avatar
17 years ago

dynamically extend xml of soap-request

Hi,

lets assume there is a soap-request that send some kind of product list:

<products>
  <product id="1">
    <name>foo</name>
  </product>
  <product id="2">
    <name>bar</name>
  </product>
</products>


the number of products that should be sent depends on the previous response. so i need to to add products dynamically to this request.

is this possible?

all i can do today, is fill the fixed structure of the request (lets say 2 products) with dynamic data, but i can't extend the structure itself to get a third product sent with the request.

any help is highly appreciated.

Torsten

2 Replies

  • omatzura's avatar
    omatzura
    Super Contributor
    Hi,

    You should be able to solve this with a property-transfer using the "Use XQuery" and new "Transfer Child Nodes" options; the XQuery is used to build the required xml from the previous response and the child-nodes option should be used with a target XPath statement that specifies the parent ("products") that will contain the created XML..

    Does that sound reasonable?

    regards!

    /Ole
    eviware.com
  • Do I need to have the Pro version of SoapUI to use the XQuery option in a PropertyTransfer TestStep?  I cannot get it to work.  Even returning a constant:
    {
    let $x := 1
    return {$x}
    }
    does not seem to work.  I have confirmed that my XPath for the destination/target was correct using XPath for the source, but cannot get XQuery working in the source.  I get java.lang.reflect.InvocationTargetException with basically anything I've tried.