Forum Discussion

AHo's avatar
AHo
Occasional Contributor
15 years ago

manipulate SoapResponse - extract CDATA-Section

Hi soapUI Community,

i have a problem with "Property Transfer".
Unfortunately I receive my response with a CDATA-Section. (see example below)


<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<ns1:callResponse xmlns:ns1="http://example.com">
<callReturn>

<![CDATA[<?xml version="1.0" encoding="UTF-8"?>

<response xmlns="http://www.test.com/test">
<serviceresult name="myService">
<array name="lib" type="library">
<object>
<string name="name">The Old Man and the Sea</string>
<string name="desc">Some text</string>
<string name="isbn">315009075X</string>
</object>
<object>
<string name="name">Alices Adventures in Wonderland</string>
<string name="desc">Lorem ipsum dolor sit amet.</string>
<string name="isbn">0688110878</string>
</object>
</array>
</serviceresult>
</response>

]]>
</callReturn>
</ns1:callResponse>
</soapenv:Body>
</soapenv:Envelope>


To call my other webservices I need the isbn of the books which is inside the CDATA-Section.
I tried these:


declare namespace tst='http://www.test.com/test';
//tst:object[1]/tst:string[@name='isbn']


As a result of CDATA this XPath Selection throws an error ("Missin match of Source XPath...").
Is it possible to manipulate the response with SoapUI and extract the "<response xmlns="http://www.test.com/test"> ... </response>" Tag?
Or can I delete the CDATA-Tag from the response before I start the "Property Transfer"?

I hope you can help me.


so long,

AHo

3 Replies

  • AHo's avatar
    AHo
    Occasional Contributor
    Hi Ole,

    awesome - that's exactly what i was looking for.
    You just made my day!
    Thank you very very much.

    best regards,
    AHo
  • rajeshbachani's avatar
    rajeshbachani
    Occasional Contributor
    I am in a similar problem but have not found a solution yet. I have referred to the link you have mentioned here Ole, but seems that does not fall entirely under the purview of my problem. Maybe you can throw some light on this one


    My server is written in Java (using Spring) and the webservices exposed are consumed in SoapUI (obviously! ).
    A typical situation we have is one major entity is encapsulated in another entity.
    So, consider object A contains object B. Object A is then passed to the Client as part of a web service, and the client needs object B (contained inside object A) to be passed as a parameter into the next webservice call.

    So, the goal in SoapUI - when we try making a test suite - is to extract object B (serialized in XML) from the received response - and use that as it is (or with some updates in certain fields) into the request for the next web service call.

    How do we achieve this?

    I am doing this:

    Retrieving object B from the return part of the response and storing it in a property at the project level.
    If I now try to parameter transfer this property in the request I end up with a CDATA[] tag in front of the entire object.
    How can this be avoided?

    Exampple:


    <A>
    <VAR1>2</VAR1>
    <VAR2>IS_A_MOBILE</VAR2>
    <B>
    <B1>2</B1>
    <B2>IS_A_RADIO</B2>
    <B3>119281c82eb9e1bd012ebb27b1c60007</B3>
    </B>
    </A>


    And "B" from this response is to be "inserted" into the request as:

    <request>
    <C>
    <C1>IS_A_MOBILE</C1>
    <C2>NOKIA</C2>
    <B>
    <B1>2</B1>
    <B2>IS_A_RADIO</B2>
    <B3>119281c82eb9e1bd012ebb27b1c60007</B3>
    </B>
    </request>


    Please bear with the formatting and the content of the example - but this is just to show what I would like to do.

    Thanks in advance,
    Raj!