Service Virtualization

  • 1.  Can someone provide JAR file to add a custom filter which would convert JSON to XML in LISA 7.5.1

    Posted Feb 18, 2016 07:34 PM

    Hi All,

     

    currently we are having a java code using JSON Object to convert the JSON to XML in which we are using jar file named org.json-20120521(got from google docs) and below is the code:-

     

    import com.itko.util.ParameterList;

    import java.lang.String;

     

    import org.json.JSONObject;

     

    // Manipulate request body text

    String theBody = lisa_vse_request.getBodyText();

    //lisa_vse_request.setBodyText("theBody");

    testExec.setStateValue("theBody",theBody);

     

     

    JSONObject o = new JSONObject(theBody);

    String xmlResult = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><JSON2XML>";

    xmlResult += org.json.XML.toString(o) + "</JSON2XML>";

    testExec.setStateValue("XML",xmlResult);

     

    Kindly let me know how can we create a custom filter to perform this feature?



  • 2.  Re: Can someone provide JAR file to add a custom filter which would convert JSON to XML in LISA 7.5.1

    Posted Feb 19, 2016 04:21 PM

    Hi Vinit, the 7.5.1 docs may no longer be online - not sure.  Here are some links from 8.0 and 8.5 describing how to create custom filters.  The process for creating a filter has remained the same for quite a few releases.  The compiler used to compile your JAR is about the only difference.

    Extending Filters - DevTest Solutions - 8.0 - CA Technologies Documentation

    Extending Filters - DevTest Solutions - 8.5 - CA Technologies Documentation

     

    At a high level, you could add the code above as an override to the subPostFilter method.  But you also need to create initialize() and getParameters() methods in addition to defining a few other properties and methods to complete the filter.

     

    As you are also probably aware, you can convert the JSON into XML when the request hits the LISTEN step using a Scriptable DPH or by rolling your own custom DPH.  I believe you already know this since I see the lisa_vse_request.setBodyText(theBody) line that is commented out in your code.  Thanks, Joel

      



  • 3.  Re: Can someone provide JAR file to add a custom filter which would convert JSON to XML in LISA 7.5.1

    Posted Feb 21, 2016 02:49 AM

    Hi Joel,

     

    Thanks for the information provided by you. I will try to do it and let you know in case of any issues or concerns.

     

    Thanks,

    Vinit



  • 4.  Re: Can someone provide JAR file to add a custom filter which would convert JSON to XML in LISA 7.5.1

    Posted Feb 22, 2016 02:18 AM


    Hi,

     

    i have jar files to help you,but unable to upload here.

     

    Thank

    Jaya



  • 5.  Re: Can someone provide JAR file to add a custom filter which would convert JSON to XML in LISA 7.5.1

    Posted Feb 22, 2016 05:11 PM

    Hi Jaya,

     

    Thanks alot for your response. Could you please mail me the .jar file after changing it to .txt file. Email id is vinit.malhotra@anz.com. I would be highly obliged for the same.

     

    Thanks,

    Vinit



  • 6.  Re: Can someone provide JAR file to add a custom filter which would convert JSON to XML in LISA 7.5.1

    Posted Feb 23, 2016 05:21 PM

    Hi Jaya,

     

    Were you able to send the JAR files by making it to .txt file on my email address? It would be of great help.

     

    Thanks,

    Vinit

    vinit.malhotra@anz.com



  • 7.  Re: Can someone provide JAR file to add a custom filter which would convert JSON to XML in LISA 7.5.1

    Posted Feb 25, 2016 12:40 AM

    Done....



  • 8.  Re: Can someone provide JAR file to add a custom filter which would convert JSON to XML in LISA 7.5.1
    Best Answer

    Posted Feb 25, 2016 03:04 AM

    Thank lot Jaya. Will see to.it. please send it to vinitmalhotra4@gmail.com also as I can't send any personal mail from corporate I'd. Appreciate the help