Service Virtualization

 View Only
  • 1.  Getting Binary response!!!

    Posted Apr 07, 2016 06:32 AM

    Hi All,

     

    I am stuck up with a scenario. I have got a pair of Request-Response & i am trying to create a VS with that. While using RR pair approach in DevTest 8.4, I am getting a pop-up warning(attached) and after clicking "OK" and generating vsm & vsi files, I am seeing some binary data in my Response section, under "Body" tab. I have attached the screenshot for this along with my VSM, VSI files and RR pair.

     

    Kindly look into this & guide me to resolve this issue.

     

    Regards,

    Aman Saeed.

    Attachment(s)

    zip
    GetH1Indicator-req.xml.zip   933 B 1 version
    zip
    GetH1Indicator-rsp.xml.zip   666 B 1 version
    zip
    newimage.vsi.zip   3 KB 1 version
    zip
    newimage.vsm.zip   1 KB 1 version


  • 2.  Re: Getting Binary response!!!
    Best Answer

    Posted Apr 07, 2016 09:49 AM

    Hi Aman, I believe you are dealing with a UTF-16 Little Endian formatted XML. 

    Try playing your R/R pairs back through the recorder. 

    When you get to the panel in the Wizard where you point to your R/R Pairs, add "UTF-16LE" in the Encoding parameter immediately above the Transport Protocol. 

    Configure your endpoint.  When you CLICK Next, the Wizard will most likely pick up that the request is XML and insert the SOAP DPH. 

    Finish out your recording and check your VSI.  When I did this in v9.1, I can see a response containing an XML Document / DOM object.

    UTF-16LE.JPG



  • 3.  Re: Getting Binary response!!!

    Posted Apr 07, 2016 09:56 AM

    Hi Joel,

     

    I confirmed it also works in 8.4 - thanks!

     

    Sincerely,

    Casey Best

     

    Sr. Principal Consultant

    CA Service Virtualization – Application Delivery – CA Technologies Canada



  • 4.  Re: Getting Binary response!!!

    Posted Apr 07, 2016 10:19 AM

    Question for the experts -- What happens in the generated VSM?  Does Aman need to add any sort of conversion from Little Endian to UTF-8 using a Scriptable DPH in the LISTEN step for payloads to parse and playback correctly?

     

    I am like Casey in that I have never really run into unicode encodings. 

    I noticed that the recorder generated a proper VSI.  But, the VSM (Listen Step) only contains the SOAP DPH. 

    I do not see any signs of applying the "LE" encoding on incoming requests by the VSM. 

     

    Code below for example purposes only -- not sure this how it would work:

    try {
       byte[] bodyBytes = lisa_vse_request.getBodyAsByteArray();
          lisa_vse_request.setBody( new String(bodyBytes, "UTF-8") );

    } catch (UnsupportedEncodingException e) {

       // TODO:
    }

    If the answer is "yes he needs to add in a conversion", the Scriptable DPH would be the first DPH in the chain and occur prior to the Soap DPH.



  • 5.  Re: Getting Binary response!!!

    Posted Apr 07, 2016 10:24 AM

    Hi Joel,

     

    Thanks for your prompt response. I would try to implement this approach.

     

    Thanks,

    Aman Saeed.



  • 6.  Re: Getting Binary response!!!

    Posted Apr 07, 2016 09:51 AM
      |   view attached

    Hi Aman,

     

    The rr pairs you provided are in “UCS-2 LE BOM” character encoding, even though the XML indicates it is in “utf-16”. As a test, I converted the file to UTF-8, and it generated the correct service image. I’m not an expert in working with multiple character encodings, so I will let someone else answer here on how to best fix the problem, but that is the underlying issue you are hitting.

     

    Sincerely,

    Casey Best

     

    Sr. Principal Consultant

    CA Service Virtualization – Application Delivery – CA Technologies Canada



  • 7.  Re: Getting Binary response!!!

    Posted Apr 07, 2016 10:21 AM

    Hi Casey,

     

    You are correct. Here, the data was in "UTF-16 Little Endian" format. So while creating the VS, if encoding is set to "UTF-16 Little Endian", it would resolve this issue.

     

    Thanks,

    Aman Saeed.



  • 8.  Re: Getting Binary response!!!

    Posted Apr 22, 2016 02:04 AM

    Hi Casey,

     

    I tried mentioning the encoding as "UCS-2 LE BOM", while creating the VS through RR-pair, but the result is still not desirable. I am not getting proper VSI file.

    I have attached the screenshots to support my query. Kindly guide me in resolving this.

     

    Regards,

    Aman Saeed.



  • 9.  Re: Getting Binary response!!!

    Posted Aug 02, 2016 09:38 AM

    Hi Aman,

     

    Good day...

    Facing same issue after transactions(transactions are in binary format) are recorded i am expecting in text format in VSI file with below code:

    byte[] b = lisa_vse_response.getBodyBytes();

    String s = new String(b, "x-IBM1025");

    lisa_vse_response.setBodyText(s);

     

    If you got any fix please share with us

     

    Thanks

    Jaya