Forum Discussion

pkottu's avatar
pkottu
Occasional Contributor
7 years ago

Working with JMS Virt --> how to extract jmsBytesMessage from req and convert to xml using groovy

Hi there,

 

I am creating a JMS Virt using ReadyAPI 2.0, everything works fine as long as the request received is set as text by the application. There are instances where application doesn't set it as text and so i receive the message in bytes.

 

Can someone please help in extracting the body and convert it into xml.

 

3 Replies

  • pkottu's avatar
    pkottu
    Occasional Contributor

    I have tried the below...

     

     

    int length = new Long(mockRequest.message.getBodyLength()).intValue();
    byte[] b = new byte[length];
    mockRequest.message.readBytes(b, length);
    String text = new String(b, "UTF-8")

     

     

    This gives me the length but not the actual bytes and converted into text. 

     

    Appreciate your help in this regard

    • nmrao's avatar
      nmrao
      Champion Level 3
      How about the below?

      log.info mockRequest.message.text
      • pkottu's avatar
        pkottu
        Occasional Contributor

        Hi nmrao,

         

        Thanks for your reply... i have tried "log.info mockRequest.message.text"

         

        looks like the operation is not applicable, attached is the screenshot for the same