Service Virtualization

  • 1.  How to change CRLF to LF line code VSI

    Posted Jan 25, 2018 12:07 AM

    Hi All,

     

    When Vservice is publishing the response to Front end which is getting resposne in CRLF line code. They need the response in LF line code. Front end asked us to change to LF line code in LISA. I realised LISA installed in windows OS and Front end system installed in Unix OS. Because of this they are getting CRLF line code.

     

    And I am new to this issue. Can anyone help me out off this?

     

    Thanks,
    Suresh N



  • 2.  Re: How to change CRLF to LF line code VSI

    Posted Jan 25, 2018 06:31 PM

    Take this with a grain of salt because I do not know exactly what the response content from your VSI looks like. 

    But.... In the VSM's Responder Step, under Filters -> Virtual Service Environment -> Data Protocol Filter, add a Scriptable DPH. In this DPH, add code to replace CRLF with LF. For example,  

    If you have magic strings that also contain CRLF, you should probably add theBody = testExec.parseInState(theBody); before the replaceAll to get everything packaged up correctly. 

     

    Let us know what happens.



  • 3.  Re: How to change CRLF to LF line code VSI

    Posted Jan 29, 2018 02:02 AM

    Hi Joel,

     

    I tried with above script. Later one of the line was changed to LF of the response. Still rest of the lines are CRLF line code.

    Request - SWIFT format

    Response - XML format

     

    Please find the below screen shot for VSresponse. It is XML message.

     

    Any another idea to chagne CRLF to LF line code?

     

    Thanks,

    Suresh N



  • 4.  Re: How to change CRLF to LF line code VSI

    Posted Jan 30, 2018 06:46 AM

    Hi Joel,

     

    Can you please have a look into above and help me out?

     

    Thanks,

    Suresh N



  • 5.  Re: How to change CRLF to LF line code VSI

    Posted Jan 30, 2018 07:56 AM

    In the VSMs Responder Step, are there any DPHs in the Filters? If so, the Scriptable DPH needs to be the last DPH FIlter in the list. 



  • 6.  Re: How to change CRLF to LF line code VSI

    Posted Jan 31, 2018 07:16 AM

    Hi Joel,

     

    There are two filters i amusing in VSM responder step. First is "Save property file" and second is "DPH filter" which is the last in list. Still its not converting to LF from CRLF.

     

    Please find the screen shot for the same and also find the screen shot for the code what i used.

     

    Can you please guide me where i am missing?

     

    Thanks,

    Suresh N



  • 7.  Re: How to change CRLF to LF line code VSI
    Best Answer

    Posted Jan 31, 2018 08:20 AM

    The above DPH code uses the string replaceAll method, so I am not certain why only one CRLF is changing.

    As FYI, Filters execute in the order they are defined therefore, the save file filter will not have any LF changes applied -- in the event you are saving and checking the XML using the output of that filter.

     

    Try running a test using the following and review the output in the log files.

    Then, enclose a print out of the the response from the consumer application's log file:

    import com.itko.lisa.remote.utils.XMLUtils;

    // perform magic string replacement

    String theBody = testExec.parseInState( lisa_vse_response.get(0).getBodyAsString() );

    // remove the pretty print line breaks from the XML

    theBody = XMLUtils.dirtify( theBody );

    // change last CRLF to LF

    theBody = theBody.replaceAll("\\r\\n", "\\n");

    // put changes back into the body

    lisa_vse_response.get(0).setBody( theBody );

    // the log files will contain a single line display rather than pretty print XML

    _logger.info("<<< your lisa_vse_response is: ");

    _logger.info("{}", lisa_vse_response.get(0).getBodyAsString() );
    _logger.info("<<< end of your response");

     

    Remove the _logger.info lines before deploying the VSM into production. These are for debugging only.



  • 8.  Re: How to change CRLF to LF line code VSI

    Posted Feb 01, 2018 05:02 AM

    Hi Joel,

     

    Please find the attached screen shot which is the log file of the response what LISA is publishing to Front end System. Last line/tag(</MESSAGE>) is converting into LF rest all are remain as CRLF still. I tried with above coding. Do we need to change repalceAll() method with anything?

    Its starage to resolve the issue.

     

    Any alternative way to convert LF from CRLF?

     

    Thanks,

    Suresh N



  • 9.  Re: How to change CRLF to LF line code VSI

    Posted Feb 01, 2018 08:51 AM

    I suggest opening a ticket to discuss this with support. The dirtify() method should have removed the intermediate carriage returns and the replace all would have covered the last CRLF. I have seen DevTest's UI treat XML as though it should be formatted.



  • 10.  Re: How to change CRLF to LF line code VSI

    Posted Feb 01, 2018 09:13 AM

    I will raise a case.