Author |
Message
|
kash3338 |
Posted: Tue Apr 07, 2009 5:22 am Post subject: Doubt on getting byte array from Java program to ESQL |
|
|
Shaman
Joined: 08 Feb 2009 Posts: 709 Location: Chennai, India
|
Hi,
I have a scenario where in I want to invoke a Java method from ESQL and that method has byte array as return type. Now i want to get that byte array in my ESQL and process it.
Currently i am using this code to invoke the static java method:
CREATE PROCEDURE MYJAVA()
RETURNS BLOB
LANGUAGE JAVA
EXTERNAL NAME "<my class path>";
I am calling this procedure in ESQL through a CALL statement and storing the return byte array in an local environment variable.
But when i use that BLOB data, actually some data are missing in it. May be i should do some Encoding/Decoding to the return data.
Can anyone please guide me on this?
Regards,
Kashyap. |
|
Back to top |
|
 |
WMBDEV1 |
Posted: Tue Apr 07, 2009 5:29 am Post subject: |
|
|
Sentinel
Joined: 05 Mar 2009 Posts: 888 Location: UK
|
Which bits are missing?
Are you sure they are present when Java returns the array? How do you know? have you printed the data to a file for example? |
|
Back to top |
|
 |
kash3338 |
Posted: Tue Apr 07, 2009 5:33 am Post subject: |
|
|
Shaman
Joined: 08 Feb 2009 Posts: 709 Location: Chennai, India
|
WMBDEV1 wrote: |
Which bits are missing?
Are you sure they are present when Java returns the array? How do you know? have you printed the data to a file for example? |
Yes i am sure they are present when java returns because i have written it to a file and i am getting a proper output. But when i create a file through MB with the returned BLOB data, it says some information missing.
Actually i have to create a ".png" file from this byte array data and later convert it to ".jpeg" file. When i try to convert the ".png" to ".jpeg" i get this error. |
|
Back to top |
|
 |
mqjeff |
Posted: Tue Apr 07, 2009 5:54 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Maybe you're doing the wrong thing when writing the file "through WMB".
To confirm if it's the Java->ESQL stage that's "removing data", you can do an additional ESQL->Java stage and call another procedure that will write the BLOB data.
This will tell you for sure whether the BLOB has all of the right data.
Or you can set up a Trace node and have that write the BLOB data.. although whether a trace node will show you the entire contents of a BLOB string depends a bit on what level of WMB you're at - there are some bugs in this area. |
|
Back to top |
|
 |
p.cradwick |
Posted: Tue Apr 07, 2009 10:34 am Post subject: |
|
|
Acolyte
Joined: 16 May 2001 Posts: 56
|
Just a thought...It wouldn't be CR/LF that are missing would it? That is what happens if you FTP a picture file as ASCII instead of BINARY. Are you doing anything when you get the data back in ESQL that might make broker think it is a text file, like parsing it to XML?? |
|
Back to top |
|
 |
mqpaul |
Posted: Wed Apr 08, 2009 5:13 am Post subject: Just to be clear, you're not expecting Broker to convert? |
|
|
 Acolyte
Joined: 14 Jan 2008 Posts: 66 Location: Hursley, UK
|
kash3338 wrote: |
Actually i have to create a ".png" file from this byte array data and later convert it to ".jpeg" file. When i try to convert the ".png" to ".jpeg" i get this error. |
I presume this conversion is outside the broker. I believe the two ways to encode images are wildly different, and what's valid for .png isn't valid for .jpeg.
You could be losing data when passing from Java to ESQL, or from ESQL to file. If there's data encoding going on, you could get all sorts of contact admin problems. Both png and jpeg are unencoded binary data (i.e. not UTF-8/ASCII/ISO 8859-1 characters). But using BLOBs should avoid issues.
How are you writing the file? _________________ Paul |
|
Back to top |
|
 |
mqjeff |
Posted: Wed Apr 08, 2009 5:30 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
I've run into something recently that appears the same way.
I was reading a MIME message using JavaMail, and was getting corruption on a binary attachment by using a BufferedReader on the InputStream.
When I switched to just using the InputStream directly into a ByteArrayOutputStream, I didn't have any trouble putting the result of toByteArray into an MbElement. |
|
Back to top |
|
 |
|