Hi, Does anyone have a sample code or reference links on how to send and read binary data in xml. I mean instead of attachment, you can attach files in binary format in xml using base64 to hexadecimal, I cann't use Saaj or axis so I need to put the attachment in xml. Any links or samples would be appreciated.
Thanks, -DV
Balaji Loganathan
author and deputy
Bartender
Joined: Jul 13, 2001
Posts: 3150
posted
0
Like how you sting as returntype,use byte[]as return type in ur method/operation Example public byte[] GetFileByteArray(String inputfilename){ // code }
Thanks Balaji. I will try that approach. If you look at the <Data> field in below xml, don't I need to decode it using some kind of base 64 decoder. Once again tanks for your response.
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 12267
1
posted
0
Yes, binary data must be encoded, typically as base64. Recall that XML has to be Unicode text - there are many binary values that are not valid Unicode characters and will cause a XML parser error. Bill
Dharamvir (DV) Punia
Ranch Hand
Joined: Oct 04, 2004
Posts: 34
posted
0
Hi William, I don't have to worry about encoding here, all I have to worry about is decoding.
This is the scenario: I will receive a post request on a servlet which will have the xml data with binary , so I have to parse the xml document and the node elements, and one of node elements would be binary attachment. What Can I use to decode it, wouldn't Balaji's approach work in this case. If you can, Can you post some links to reference sites or sampes on how to decode it using base64 or anyother way, It doesn't matter what apprach I use, all I care about is getting the binary data. Thanks, -DV
William Brogden
Author and all-around good cowpoke
Rancher