Service Virtualization

 View Only
  • 1.  Will the special characters in JMS Input message body be truncated in VS?

    Posted Aug 25, 2017 07:28 PM
      |   view attached

    Greetings Team,

     

    I am in the process of creating a JMS based Virtual service, below is the Input message pattern

     

    It has special characters, please find attached for reference.

     

    1. Will DevTest truncate the special characters, while importing the Request-Response pair?

    2. What DPH should I use?

     

    Note:- Response is almost similar, with additional 2 elements

     

    Thanks in advance.

     


    YASAAAA
    .FCDEFG
    ***
    FGHTYF
    111-23467890-M
    AAA/BBB/C000000/B000000/E L, *** TO ***
    BBB/***0000/25AUG
    PHP/XXXXX  SS
    /AMERICAS BLRH
    /PARIS /CFT
    /cc/99999
    gfg/XXXXX  SS
    /67576 uygfhjhj RD
    /MEMPHIS/TN
    /IN/654564
    TRDD//99999-YYF

     

    Your inputs would be very much appreciated.

    Attachment(s)

    zip
    Req_Res.txt.zip   316 B 1 version


  • 2.  Re: Will the special characters in JMS Input message body be truncated in VS?

    Posted Aug 26, 2017 09:17 AM

    No characters will be truncated. Special characters related to XML will the escaped 

     

    Symbol (name)

    Escape Sequence

    < (less-than)

    &#60; or &lt;

    > (greater-than)

    &#62; or  &gt;

    & (ampersand)

    &#38;

    ' (apostrophe or single quote)

    &#39;

    " (double-quote)

    &#34;

     

    If the request is in the above format you might have to write custom data protocol handlers to parse the request into arguments.  or Delimited Text Protocol Handler and provide the delimiter. 

     

    If you still get invalid XML Character errors, I identify the character and change it Escape sequence character.  

     

     

    Thanks,

    Vamsi K



  • 3.  Re: Will the special characters in JMS Input message body be truncated in VS?

    Posted Aug 26, 2017 01:11 PM

    Your request contains 0x01, 0x02, and 0x03 characters.  It should be okay, although what happens with the request will depend on the Data Protocol Handler(s) you are using.  The response should be fine as well.  However, you want to make you have msg.type = javax.jms.TextMessage in the response meta-data; otherwise it may end up being sent as a BytesMessage.



  • 4.  Re: Will the special characters in JMS Input message body be truncated in VS?

    Posted Aug 27, 2017 04:08 AM

    Greetings Kevin,Vamsi,

     

    Thanks for the responses.

     

    I am working on DevTest v9.0.0 and have selected DPH has Delimited Text with magic.string variable set to both.

     

    When the VS image is created, Request side there are no arguments created.

     

    Please let me know, if any specific sequence of dph needs to be used.



  • 5.  Re: Will the special characters in JMS Input message body be truncated in VS?

    Posted Aug 28, 2017 10:30 AM

    Greetings Kevin,

     

    I updated the Request as below with the control escape characters, and now DevTest is populating Request side arguments with Delimited Text DPH

     


    &#x1;YASAAAA
    .FCDEFG
    &#x2;***
    FGHTYF
    111-23467890-M
    AAA/BBB/C000000/B000000/E L, *** TO ***
    BBB/***0000/25AUG
    PHP/XXXXX SS
    /AMERICAS BLRH
    /PARIS /CFT
    /cc/99999
    gfg/XXXXX SS
    /67576 uygfhjhj RD
    /MEMPHIS/TN
    /IN/654564
    TRDD//99999-YYF
    &#x3;

     

    Should I do any other changes or configure anything in addition?



  • 6.  Re: Will the special characters in JMS Input message body be truncated in VS?

    Posted Aug 29, 2017 01:28 PM

    Does that work at playback time?  Does the response in the resulting service image contain "{{...}}" magic strings?

     

    I don't currently have the bandwidth to test this out myself, but your request and response are technically *not text*.  They are *binary* because they include unprintable characters (anything from 0x00 - 0x19).  I don't know for sure how everything will react to that without testing it.



  • 7.  Re: Will the special characters in JMS Input message body be truncated in VS?

    Posted Aug 30, 2017 07:43 AM

    Greetings Kevin,

     

    No its not working during playback.

     

    However I created a VS with Request-Response payload containing the Binary characters, as is. When a Request enters VS , it is responding back with the configured response.

     

    The issue I am facing is, Magic string are not created and not able to see any arguments in Request side.

     

    In another post "Getting Binary response!!! ", the problem seemed to be resolved by specifying the Encoding type.

     

    Will this help me in this scenario? What is the encoding method for that I need to specify?

     

    Thanks in advance.



  • 8.  Re: Will the special characters in JMS Input message body be truncated in VS?
    Best Answer

    Posted Aug 30, 2017 02:33 PM

    The post you linked was about data that actually is text, just with a different encoding.  With your data, there is no encoding that makes it actually text.  The unprintable 0x01, 0x02, and 0x03 characters will apparently not make it past the various "sanity checks" in the VSE code that try to separate text from binary.

     

    In the absence of a data protocol built for your particular message format, you can use some Scriptable Data Protocols that will convert your RR pairs to something that passes for text, and then reverse that conversion at playback time.

     

    On the Data Protocol selection screen, add a Scriptable Data Protocol then the Delimited Text Data Protocol on the request side.  Add another Scriptable Data Protocol on the response side.  It should look like this:

     

    Next, you will be asked to configure those data protocols.  The first Scriptable Data Protocol should have a single 'Request' tab.  Put the following code in there:

     

    %beanshell%
    String text = lisa_vse_request.getBodyText();
    text = text.replaceAll("\\u0001", "(0x01)/");
    text = text.replaceAll("\\u0002", "(0x02)/");
    text = text.replaceAll("\\u0003", "(0x03)/");
    lisa_vse_request.setBodyText(text);

     

    This will replace the unprintable characters with something printable before they become a problem.  This will allow the Delimited Text Data Protocol to see the request body as text and do its job.  After this will need to configure the Delimited Text DPH.

     

    The second Scriptable Data Protocol will have two tabs.  For 'Response - Record', use this:

     

    %beanshell%
    String text = lisa_vse_response.getBodyText();
    text = text.replaceAll("\\u0001", "(0x01)/");
    text = text.replaceAll("\\u0002", "(0x02)/");
    text = text.replaceAll("\\u0003", "(0x03)/");
    lisa_vse_response.setBodyText(text);

     

    It's identical to the first one, except it uses lisa_vse_response instead of lisa_vse_request.  This will allow VSE to see the response as text and put in magic strings.

     

    For the 'Response - Playback' tab, we will have to reverse the conversion on the response:

     

    %beanshell%
    String text = lisa_vse_response.getBodyText();
    text = text.replaceAll("(0x01)/", "\\u0001");
    text = text.replaceAll("(0x02)/", "\\u0002");
    text = text.replaceAll("(0x03)/", "\\u0003");
    lisa_vse_response.setBodyText(text);

     

    See if that works for you.  At the end of the recording session, make sure to use the little save button in the lower right corner because you do not want to enter all that again from scratch.



  • 9.  Re: Will the special characters in JMS Input message body be truncated in VS?

    Posted Aug 31, 2017 05:50 AM

    Greetings Kevin,

     

    Thanks for the quick reply.

     

    Your solution is working like a charm ....

     

    Good day!!!