Message Object Output

rvmsengrvmseng Posts: 53
edited May 22 in Virtualize

Hi every body,

Message Object Output does not exist for virtualization incoming request, I need convert input to BytesMessage, but I have faced with error (String cannot be cast to BytesMessage).

Note: I can use Message Object Output in SOATest but it does not exist in Parasoft virtualization, please refer to below link :

please refer to my scenario:


  • keegan_chankeegan_chan Posts: 44

    Internally, Virtualize converts the message into a string. You can try using the String.getBytes(charsetName) method to get it as a byte array.

  • rvmsengrvmseng Posts: 53
    edited May 23

    Dear Keegen,

    I used following code, but I still have error (java.lang.RuntimeException: javax.crypto.BadPaddingException: Decryption error)

    My Code:

     public String decrypt(Object input) throws JMSException {
       CryptographyUtil c = new CryptographyUtil();
       Charset charset = StandardCharsets.ISO_8859_1;
       byte[] bytes = ((String)input).getBytes(charset);
       return new String(c.decryptToByte(bytes));

    I sure this error is belong to following line:
    byte[] bytes = ((String)input).getBytes(charset);

  • rvmsengrvmseng Posts: 53
    edited May 23

    Also I tried utf8 and utf16 but issue exist yet
    My input request body was increapted by RSA
    And i have to decrypt it befor extracting data

    Please give me a solution

  • williammccuskerwilliammccusker Posts: 82

    The exception you are seeing, javax.crypto.BadPaddingException, is most likely coming from the call to "decryptToByte" this may be due to the bytes not being correctly created using to proper charset. If you monitor the virtual asset you should be able to look at the incoming request to see what the actual charset of the message was. Then use that same charset in your script.

  • rvmsengrvmseng Posts: 53

    Dear williammccusker,

    I checked your solution but it isn't work.
    also I find that when I use "Message Object Output" request body length is 128 byte (fix), but when I convert input (Object) to "Sting" request body length changed dynamically and not fixed 128 byte.

    please help me.

  • rvmsengrvmseng Posts: 53

    When parasoft virtualization convert input to string it lost incoming request body data
    Please give me a solution

  • jakubiakjakubiak Posts: 371 admin

    I suspect that you are correct that the conversion to string is corrupting the bytes. You may be able to work around this by setting the default encoding in the preferences to ISO-8859-1, which would encode the bytes to String the same way that you are decoding them in your script. Doing this should preserve the bytes. You can set the character encoding in the Misc tab of the Parasoft preferences.

  • rvmsengrvmseng Posts: 53

    Dear jakubiak,

    I checked your solution but unfortunately it does not work, I don't understand why Parasoft virtualization don't have "Message Object Output"? or why it convert Object to String?

    please help me.

  • williammccuskerwilliammccusker Posts: 82

    It looks like what happens is that for jms we default to using "UTF-8" as the encoding and it doesn't consider what was set in the preferences. This causes use to convert the bytes into a string for the extension tool.

    I am attaching a java example of using internal api to get the raw bytes from the incoming request. Could you try it out and let us know if that resolves the issue?

  • rvmsengrvmseng Posts: 53
    edited May 25

    Dear Williammccusker,

    I have received "null pointer exception" for following line:

    Application.showMessage("--- StubBatchContext = " + sbctx.getClass().getName());
            Method getIncomingMessage = sbctx.getClass().getMethod("getIncomingMessage");

    I suppose this object "sbctx" is null.
    I print map value and it return following:

    {TEST_EXECUTION_LISTENER=[[email protected]]}

  • williammccuskerwilliammccusker Posts: 82

    Hi, I just confirmed it works for 9.10.3 when I send a JMS message to the asset. How are you invoking that asset? JMS? Or some other protocol?

  • rvmsengrvmseng Posts: 53

    Dear williammccusker,

    Thank you so much, It is solved.
    you are very good supporter.

    thank you.

Sign In or Register to comment.