XStream is working great for me. Now I need to serialize/deserialize an image file (e.g. .png, .img, etc) which is inside my XML HTTP message. I am using Hibernate 3.0 (Annotations).
I did some digging for the info but I couldn't find examples or mentionings on how to serialize, and few for deserialize.
Can someone give me some info/examples on how to do them, please?
Currently, I have this code segment:
The returned string was formatted in XML simply as a string. I have *.png files embedded in the XML content and I need to send them as is in binary (not the file name) properly between 2 XML tags and the rest string.
I was thinking more on the line of using @Lob, byte for my image fields on my POJOs and hoping that they will be serialized/deserialized to MySQL and become longblob type.
Since you cant include arbitrary binary directly in XML, you must encode it in legal XML characters
Are you referring to the CLOBs and BLOBs and from converting BLOBs to Byte and back, that kind of conversion? That is what I have in mind but I am seeking an example of how this is done in a more complete context, instead of 2/3 line code segments.
Sorry, I wasn't too clear.
Any help will be greatly appreciated.
Author and all-around good cowpoke
Joined: Mar 22, 2000
Are you referring to the CLOBs and BLOBs and from converting BLOBs to Byte and back, that kind of conversion?
No, I a referring to the fact that the byte of image data can not be inserted in a SOAP message directly because there are many byte values which are not legal as XML characters.
I have NO idea what facilities Hibernate 3.0 provides so you are on your own there.
Joined: Mar 05, 2010
Thank you so very much for your reply and clarification, Bill. I really appreciate it.
I finally got it working using Hibernate 3 Annotations and XStream. The code required is very little, very clean and concise. It was my oversight of error in my code and I created the problem for myself.