Requirements : Client calls the webservice or EJB to get the pdf file stored in database @ server side .
In my case , the pdf is stored in oralce database as Blob .The first step is to get the byte[] of the pdf file .It's not a problem. After that , the problem comes up that how to transfer the byte[] to client ? In my case ,the data format is XML .As known , XML contains data of string format .That is to say ,converting the byte[] to be in string format is the key point .
The solution is : Convert the byte[] to String by using JDK API,which contains a function to convert the byte[] to be string encoded in BASE64 .
Sample :
Now you get the encoded string in BASE64 for the byte[] of pdf file . Transform the encoded string to client and do the decoding for the encoded string by using the method "decodeBuffer(String encodedString)" to get the byte[] . Get the byte[] , get the pdf file .