Service Virtualization

  • 1.  How to extract payload data from xml?

    Posted May 01, 2017 03:12 AM

    Hi,

    While creating IMS service we need mapping file, copybook(req&rsp) and data(req&rsp). After successfull creation of IMS service we get response in xml(in vsi). It is with the use of copybook filter,

     

    So my query is, if i need to reverse the process i.e i need to extract data from response xml which is totally depending on size of copybook. How to achieve this?

     

    It will be really helpful if i created a IMS stub one year before and i need to check the data that we are sending in vsi response.

     

    Waiting for quick response.

     

    Thanks in advance.



  • 2.  Re: How to extract payload data from xml?

    Posted May 01, 2017 11:47 PM

    Have you tried capturing the parameter of {{lisa.vse.response}}?



  • 3.  Re: How to extract payload data from xml?

    Posted May 08, 2017 09:30 AM

    Hi Eric,

    Thank you for providing details. But using above property, we can extract response from step. But i need to extract data between the arguments. 

    For Ex: 

    <Details>

    <name>Sumeetsingh</name>

    <lastName>Thakur</lastName>

    </Details>

     

    I need output as

    Sumeetsingh Thakur



  • 4.  Re: How to extract payload data from xml?

    Broadcom Employee
    Posted May 08, 2017 11:06 AM

    If you have the response in a property then creating a XML XPath filter on the XML element should help you.



  • 5.  Re: How to extract payload data from xml?

    Posted May 08, 2017 09:24 AM

    Sumeetsingh,

     

    Did Eric's recommendation help you out regarding this issue?

     

    Regards,

    Reid



  • 6.  Re: How to extract payload data from xml?

    Posted May 08, 2017 11:36 AM

    And Using filters (xml or Jason) on particular elements returns exact value and you can save in properties for later you.  Incase you want display extended properties together you can use as needed.

     

    Hope this helps!!

    Thanks ,

    Rajesh k Singh



  • 7.  Re: How to extract payload data from xml?

    Posted May 09, 2017 12:58 AM

    With the use of XML XPath filter, we can extract value values from arguments individually. 

     

    What if i am having hundreds of elements in my response? Using XML XPath filter for all of them is not feasible. Also i need my data to be length specific.I am having a xml file which contains several arguments tags. origin-length is a parameter which contains length of data. If data is absent then length of tag is replaced by space

     

    For ex: 

    Input:

    <FZMLTH-TRAN-CODE-NAME left-pad-length="0" origin-length="8">FZE13MP</FZMLTH-TRAN-CODE-NAME>
    <FZMLTH-DELIMITER left-pad-length="0" origin-length="2" />
    <FZMLTH-ENCODING left-pad-length="0" origin-length="4" />
    <FZMLTH-COUNTRY-CODE left-pad-length="0" origin-length="2">AU</FZMLTH-COUNTRY-CODE>

     

    Output:

    FZE13MP       AU

     

    From above you can see, length is replaced by "space" between FZE13MP and AU

     

     PFA sample image for reference.

    Output File 

    Output file which contains extracted elements. Data is specific to length.

     

    Input File

    Input file which contains arguments and data. Data is specific to origin-length mentioned in arguments



  • 8.  Re: How to extract payload data from xml?
    Best Answer

    Broadcom Employee
    Posted May 09, 2017 10:29 AM

    Hi Sumeet, I think the filters should help you, could you please open a support ticket and I can look into this issue.



  • 9.  Re: How to extract payload data from xml?

    Posted May 19, 2017 02:01 AM

    Thank You gadpr08 kadne01 for yesterdays WebEx.

     

    Hi All,

    As the problem remains unresolved, can you please help me with this. 

     

    Background: I need to extract payload from xml. Payload should be such that, if there are no data in fields/tags, it should be replaced by space(Depending on argument "origin-length" present in tag)

     

    For further details please refer above mentioned comments or feel free to get in touch with me.

     

     

    Thanks in Advance,

    Sumeet



  • 10.  Re: How to extract payload data from xml?

    Posted Jun 05, 2017 06:36 AM

    Thank You kadne01 for providing sample script.

     

    Hi All,

     

    With the use of script provided by Neelima, i was able to store response from Responder step in web service. But still i  am facing challenge in saving response in IMS service. I have added Scripted assertion in image response selection step. Used below mentioned scripts.

    i am happy that its working for web service but for IMS, nothing is getting saved.

     

    PFB script that i have use:

    import com.itko.lisa.vse.stateful.model.TransientResponse;
    responseList = testExec.getStateObject("lisa.vse.response");
    TransientResponse response = responseList.get(0);
    String respText = testExec.parseInState(response.getBodyText());
    testExec.setStateValue("responsSEl",respText);

     

    Can you please check and tell me  the reason behind the same. Also please let me know if there are any alternatives.