Forum Discussion

Finan's avatar
Finan
Frequent Contributor
14 years ago

Using the XMLHolder class for service out to service in

Hi,

I'm trying to use the XMLHolder class to modify a response received from a service and use that response as an input for a follow-up service call. Basically my setup is:

- Request soap message from server
- Modify soap message with groovy
- Send modified soap message to server

Now our setup has the following structure in service definitions:

Received message:
<soapenv:Envelope>
<soapenv:Header />
<soapenv:Body>
<responseMethodName>
<responseData />
</responseMethodName>
</soapenv:Body>
</soapenv:Envelope>

Sent message:
<soapenv:Envelope>
<soapenv:Header />
<soapenv:Body>
<sendMethodName>
<adjustedResponseData />
</sendMethodName>
</soapenv:Body>
</soapenv:Envelope>

How can I make it so that using the XMLHolder I change the name of the element <responseMethodName> to <sendMethodName> and reuse all the other data in the response message?

For now all I can think of is to use a regular expression string replace on the adjusted responseData. But what I'd rather do is to only cut out the <adjustedResponseData> element and it's contents and inject that data into the <sendMethodName> element using the XMLHolder class.

Can someone provide me a suggestion on how this can be resolved best?

2 Replies

  • Hi!

    hmm.. before jumping on the XmlHolder solution, couldn't you just use a regular PropertyTransfer for this?

    regards!

    /Ole
    SmartBear Sweden
  • Finan's avatar
    Finan
    Frequent Contributor
    Well I'm dealing with a lot of data. It would be unmaintainable to transfer every property from the result to the target message. That's why I intend to make use of the fact that the structure is almost exactly the same, so I can use the response message as the message to send (with a few modifications).

    Another part is where I have to remove a whole block from the response message. Say in our case we have a customer that consists of a "main account holder" and possibly a "partner". I have a case where I want to remove the partner, which will require me to remove the partner element from the response XML. Considering the workings of the XMLholder that class seemed like the cleanest and most mainainable solution for this.