Service Virtualization

  • 1.  Read File using regex

    Posted Oct 02, 2018 08:35 PM

    I am using "Read a File step" and I want to read a file "ABCD_EFGH.xml" .

    I wont be knowing the first part "ABCD" as the application generates that value dynamically and I can't find the value anywhere in response. But I can get the second part  ex: "EFGH" in the application JSON response with a Key.

     

    Can anyone please help me how can I read this kind of file using regex or any other way.



  • 2.  Re: Read File using regex
    Best Answer

    Broadcom Employee
    Posted Oct 03, 2018 02:02 AM

    If you have the second part “EFGH” in some property “{{mySecondPart}}” you can add a DataSet “Load a Set Of Filenames” with a file pattern “*_{{mySecondPart}}.xml” to your “Read a File Step” and use the name of the dataset as your file name.

     

    This is assuming your dataset returns only one file that fits the dataset filepattern. If there is a possibility that more files are returned then you will have to create a loop before the “Read a File Step”  and process all the filenames returned by the dataset until you hit the one you need, then from your loop-step (“Executable Script Step”?) your next action would be the  “Read a File Step” .

     

    Cheers,

    Danny



  • 3.  Re: Read File using regex

    Posted Oct 03, 2018 02:48 AM

    Thanks Danny,

     

    This solution worked for me, thanks a lot.