Message Object Output
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 :
https://docs.parasoft.com/display/SOAVIRT9103/JMS#JMS-MessageObjectOutputsforClientsUsingJMS
please refer to my scenario:
Comments
-
Internally, Virtualize converts the message into a string. You can try using the String.getBytes(charsetName) method to get it as a byte array.
0 -
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);
0 -
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 dataPlease give me a solution
0 -
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.
0 -
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.
0 -
When parasoft virtualization convert input to string it lost incoming request body data
Please give me a solution
Thanks0 -
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.
0 -
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.
0 -
Hi
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?
1 -
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=[webtool.test.EventLoggerListener@1cebf1c]}
0 -
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?
0 -
Dear williammccusker,
Thank you so much, It is solved.
you are very good supporter.thank you.
1