This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
I have image files stored in hard drive with their address stored as a field in database.
say for example, I would have CUSTOMER_ID would have "C:\IMAGE_CUSTOMERID.jpg" as its image address stored in as a varchar2 field and I want to send the actual image IMAGE_CUSTOMER_ID.jpg inside a web service.
How would you advice sending such files inside a web service. I read about sending it as binary, but can you post a sample example?
In general, sending files via web services is not recommended - specially the media files because of their potential size. Alternatives to sending the file via web service would be to make the file available via ftp or similar and send the filename/location via web service. Another option is to use JMS to send the file (but again, depending on the size this may or may not be a good idea but it definitely works better than web service).
In the past people also sent files via base64 encoding. This encoding essentially turns an image into text, which can be embedded inside a SOAP message. You can find plenty of code samples on Google to encode an image into text and decode it back to image. Again, this may make the soap message way too big and isn't a preferred method anymore.
The problem with web service attachments is that lack of supported standards. While MTOM/XOP is currently the preferred standard it is only supported by the most recent SOAP web service stacks. Earlier clients will only support a variety of even less well supported standards like DIME (not well supported under Java) and SOAP with Attachments (SwA) (not supported under .NET).
Given that you want to expose standard images it makes sense that you expose them as resources:
The samples run on Glassfish - however you should be able to run Jersey on Tomcat. Restlet even has connectors to run on web servers like Grizzly or Apache MINA which perform better than servlet-based web servers (Benchmark shows Restlet scalability). [ December 11, 2008: Message edited by: Peer Reynders ]