Testing Web Services in Glassfish 3

In Glassfish 2, the admin console had a separate node for web services.

Once there you could click on one of the services a get this page

Notice the “Test” button.  That will take you to a page that will allow you to test all of your service operations.  Handy.  But in Glassfish 3, there is no node for web services.  I was dismayed when I found this.  How will I test my service on the server?  No worries.  It’s still there.  It’s just moved, and it takes a few more clicks.

Click on the Applications node and navigate to the web application that contains the web service you want to test.  You’ll find this page detailing the application and it’s modules.

You’ll notice that under the action column you see two rows with links for View Endpoint.  When you click on that link, you will find the link for testing your service.  It’s the same page as in Glassfish 2.  It looks like this.

The result of running your operation is a display of both the SOAP Request and the SOAP Response.

This testing mechanism in Glassfish is invaluable.  Take advantage of it.

For an in depth read on web services in Glassfish, check out Java expert Aran Gupta’s article Creating and Invoking a Web service using GlassFish in NetBeans, IntelliJ, and Eclipse


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/vnd.ms-excel. 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!