Service Virtualization

  • 1.  Removing CDATA tag using scriptable data protocol

    Posted May 16, 2017 11:29 AM

    Hi All,

     

    I am trying to remove the CDATA tag in the request data using the below code in scriptable data protocol. It was removed as expected from the request and displayed in the proper XML structure in the generic XML payload parser window which is the next protocol.

     

    // Manipulate request body text
    String strRequest = lisa_vse_request.getBodyText();
    String sOutputData = null;

    sOutputData = strRequest.replace("]]>","");
    sOutputData = sOutputData.replace("<![CDATA[","");

    lisa_vse_request.setBodyText(sOutputData.toString());

     

    Once I finished creating the service, I am seeing only the below code in the model file. Does any one come across this issue, or having any other solution to remove the CDATA from the request.

     

    // Manipulate request body text

    String strRequest = lisa_vse_request.getBodyText();
    String sOutputData = null;

    sOutputData = strRequest.replace("



  • 2.  Re: Removing CDATA tag using scriptable data protocol
    Best Answer

    Posted May 17, 2017 12:12 AM

    Try adding escape

     

    sOutputData = sOutputData.replace("<\\![CDATA[","");



  • 3.  Re: Removing CDATA tag using scriptable data protocol

    Posted May 18, 2017 09:17 AM

    Hi Ajay, I can able to handle CDATA as per you code. Thanks for your suggestions.



  • 4.  RE: Re: Removing CDATA tag using scriptable data protocol

    Posted Feb 26, 2020 08:58 AM

    Hi @Ajay Kattookaran

    Could you please let me know ​where the below section needs to be added?

    sOutputData = sOutputData.replace("<\\![CDATA[","");




  • 5.  RE: Re: Removing CDATA tag using scriptable data protocol

    Posted Feb 26, 2020 10:40 PM
    In listener step -> Filter -> VS->Scriptable protocol.

    In recorder -> After recording in completed -> Request protocols ->By default (XML or REST or SOAP) would be selected. Click Add and select Scriptable protocol and then click next you would come across a screen where u can add the script.


  • 6.  Re: Removing CDATA tag using scriptable data protocol

    Posted May 18, 2017 08:14 AM

    Rajarajan,

    Did Ajay's recommendation help you out with this issue?



  • 7.  Re: Removing CDATA tag using scriptable data protocol

    Posted May 18, 2017 09:20 AM

    Hi Reid,

    Yes, Ajay's recommendation worked for me. But still I am curious to know how it worked without the escape sequences when I am creating the VSM and VSI from the RR pairs.