Forum Discussion

rajeshbachani's avatar
rajeshbachani
Occasional Contributor
15 years ago

Removing CDATA from a Soap Request

Hi folks!

I have done a lot of research on this issue; even some posts here on the forum were indicating to a similar situation - but could not find any precise help. I hope someone will be able to help me here.

So, when I do a property transfer from a project-level property which contains an XML node having not null child nodes: for example -
device property with value - <device><id1>1</id1><id2>1</id2><id3>1</id3></device>

And when I try to do a property transfer of this into a Soap request - the value fed into the request is pre-pended with a CDATA tag.
This leads to the request being ill-formed and automatic tests cannot work with this.

So, my idea was to use a groovy script snippet before submitting the request - which replaces the CDATA and other problem creating strings.

I have been able to retrieve the entire request into a String variable in groovy - and also replace the necessary strings.
But I am having no clue on how to store the same modified request back into the method request.

1. Is this possible at all? I am not using the Pro version - whih I understand can make this possible using the event listeners?
2. But anyway, just with the normal free version, if possible, how can this be achieved?

Thanks for any help!

Raj.

3 Replies

  • I have a similar problem, can't extract CDATA from REQUEST, keep getting null value.

    Request:

    <soapenv:Body>
    <ejb:messageHandler>
    <requestXml>
    <![CDATA[<bgt:rrbbksRequest xmlns:bgt="http://www.lol.si/rrbbksGlobalTypes" xmlns:rgt="http://www.lol.si/RegisterGlobalTypes" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.lol.si/rrbbksGlobalTypes ../../rrbbks_EJB/ejbModule/rrbbksGlobalTypes.xsd ">
    <bgt:Header>
    <bgt:Mid>vMiQTU9vxIunqGCq1e0toDFzomT2fAxC</bgt:Mid>
    <bgt:Operation Id="SendScannedPackageToS"></bgt:Operation>
    .
    .
    .
    .
    .
    Property transfer:

    declare namespace ejb="http://ejb.rrbbks.lol.com";
    //ejb:messageHandler[1]/requestXml[1]
  • Finan's avatar
    Finan
    Frequent Contributor
    def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context );
    def holder = groovyUtils.getXmlHolder( testStep.requestContent );
    holder.namespace ejb="http://ejb.rrbbks.lol.com";
    dev requestXml = holder.getNodeValue("//ejb:messageHandler[1]/requestXml[1]");
    log.info(requestXml);

    If you run this does your scriptlog show a null value or the Xml content?
  • BAzad's avatar
    BAzad
    New Contributor
    I would need some help in removing CDATA from a soap response
    my soap response is something like this
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soap:Body>
    <LoginResponse xmlns="http://sliderocket.com/webservices/">
    <LoginResult><![CDATA[<results requestID="" uid="" type="Login" status="1" error=""><data><Data SessionID="583df854-7de5-4248-a0ef-632e739db24e" UserID="FE5F6276-CCF7-8243-2C7F-A70CEFA5E507"><Company><uid>e63ad7cf-8968-417b-8284-23fbb43d7a22</uid><ID>30732</ID><Name>SlideRocket</Name><MaxUsers>75</MaxUsers><PrimaryUser>ee74004e-26aa-40bc-acf7-13a294380e63</PrimaryUser><PlanID>7</PlanID><Status>1</Status><CreationDate>9/3/2008 2:44:03 PM</CreationDate><ExpirationDate>1/30/2010 12:00:00 AM</ExpirationDate><DiskSpacePerUser>250</DiskSpacePerUser><PermissionByFolder>False</PermissionByFolder><VendorID>GoogleApps </VendorID><PublishID>ABTMA</PublishID><VanityName>sliderocket</VanityName><HadTrial>0</HadTrial><UseGoogleCheckout>False</UseGoogleCheckout><LastModifiedBy>273401</LastModifiedBy><LastModifiedOn>12/5/2011 1:41:40 PM</LastModifiedOn></Company><User><uid>FE5F6276-CCF7-8243-2C7F-A70CEFA5E507</uid><FirstName>Shailaja</FirstName><LastName>Madireddy</LastName><Email>shailaja@sliderocket.com</Email><Password>2f0c0313a6b193d94bbabef9675c3936</Password><CompanyID>e63ad7cf-8968-417b-8284-23fbb43d7a22</CompanyID><Preferences><Preferences>
    <autoSaveTimer>5</autoSaveTimer>
    <showDefaultThemes>1</showDefaultThemes>
    <NewPresentationDlgHeight>600</NewPresentationDlgHeight>
    <autoSaveOnChange>1</autoSaveOnChange>
    <showNewUIDialog>0</showNewUIDialog>
    <marketplaceVisit>1</marketplaceVisit>
    <customColors>
    <colors/>
    </customColors>
    <getStartedDontShow>1</getStartedDontShow>
    <NewPresentationDlgWidth>800</NewPresentationDlgWidth>
    <autoSaveOnTimer>1</autoSaveOnTimer>
    </Preferences></Preferences><AccountCreated>9/26/2011 1:44:42 PM</AccountCreated><IsSlideRocketDebugUser>False</IsSlideRocketDebugUser><IsDeleted>False</IsDeleted><OptInMarketing>False</OptInMarketing><OptInNewsletter>False</OptInNewsletter><AgreedToTOS>True</AgreedToTOS><IsBillingUser>False</IsBillingUser><ForcePasswordReset>False</ForcePasswordReset><Role>0</Role><id>393158</id><LastModifiedBy>273401</LastModifiedBy><LastModifiedOn>9/26/2011 1:44:42 PM</LastModifiedOn><EmailConfirmationStatus>0</EmailConfirmationStatus></User><Capabilities><CanEditIdentity>false</CanEditIdentity><CanAccessInspirationGallery>true</CanAccessInspirationGallery><CanAskForComments>true</CanAskForComments><CanBuyMarketplaceCredits>true</CanBuyMarketplaceCredits><CanCreateThemes>true</CanCreateThemes><CanEditFolders>true</CanEditFolders><CanEditTags>true</CanEditTags><CanExportPresentations>true</CanExportPresentations><CanImportAssetsFromDesktop>true</CanImportAssetsFromDesktop><CanImportAssetsFromWeb>true</CanImportAssetsFromWeb><CanImportFonts>true</CanImportFonts><CanImportPresentations>true</CanImportPresentations><CanPrintPresentations>true</CanPrintPresentations><CanPublishPresentation>true</CanPublishPresentation><CanShareViaEmail>true</CanShareViaEmail><CanShareWithEveryone>true</CanShareWithEveryone><CanUseColorPicker>true</CanUseColorPicker><CanUseDefaultFonts>true</CanUseDefaultFonts><CanUseDefaultThemes>true</CanUseDefaultThemes></Capabilities></Data></data></results>]]></LoginResult>
    </LoginResponse>
    </soap:Body>
    </soap:Envelope>