Revisiting the whole binary serialization/deserialization thing…

As I wrote in White Flag or Good Design Choice?, I ended up sort of waving a white flag with this issue, but I’ve lived with this choice for a little while now and I want to highlight it for the sake of one of my 2 readers.

In response to How to add a new mime type to Glassfish, I received the following question:


  1. Jeff Rubinoff Says:
    February 20, 2008 at 11:03 am e

I’m a tech writer on NetBeans at Sun, covering web services. I want to create a tutorial on sending binary data as a SOAP attachment using the MTOM, XOP and/or Swaref. It seems comparatively straightforward to send image data this way (see this tutorial but I’m wondering about sending some nasty proprietary business stuff, like pps application/powerpoint or xls application/ Do you have any suggestions?

No, but how about a rambling diatribe? Jeff, the tutorial looks awesome. I wish I’d had that when I was trying to move a PDF file with web services! I highly recommend my other reader to check it out!

JAX-WS Tutorial: Working With Binary Data

I might not have given up so easily if I’d seen this a couple of months ago. In the case of PDF, there is a great package called iText by Bruno Lowagie and Paulo Soares that might be applicable here. With Microsoft stuff…hmmmm…dunno…but I bet some clever guy or gal has written some cool package somewhere.

Here’s my thing, I didn’t want the onus of assembling binary data into a consumable format to fall on the client. I felt like the service should really do all of the heavy lifting. Wellllllllllll….I didn’t quite figure out that little bit of magic this time around. Instead, I decided to implement it with a good old-fashioned Servlet. The client makes an HTTP request to my services web application and recieves exactly what it needs: a PDF file. It’s not so bad. Like XML, HTTP is universal. In the case of files, it requires nothing proprietary and returns any kind of proprietary junk it wants to return.

Now, keep in mind that I’m a total Web Services rookie just trying to get my job done. My job is not to figure out how to do something with Web Services or Java or Servlets or this or that. All my employer cares about is that it works. In this case, Servlets worked like a charm, and I got to complete my project.

In your case, Jeff, it seems like you would need to assemble a library of APIs for your client that manipulate various proprietary formats the way iText works with PDF. You should be able to send the binary data the same way for PowerPoints and Excels as you did for images. But again, your clients are going to have to be in the business of assembling binary data into something consumable. Hey! Maybe there’s a way to type your binary data so that a browser knows what to do with it. Then, if your client is not a browser you could just embed a browser into your client. Dunno.

I’m counting on you to be much more clever and find a great JWS/Netbeans/Glassfish solution for this problem, Jeff. Keep me posted!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s