Thursday, September 25, 2008

Writing a Secure Swing Client For a Web Service

Using NetBenans IDE, I've tried to write a Swing GUI client for a secure web service that I've made. While web-based servlet works great, Swing standalone application spits weird errors and won't even run. One of the interesting exceptions is: ERROR: No security header found in the message
The problem is that NetBeans is using "old" JAX-WS libraries instead using WSIT. Solution is to remove all the JAX-WS jar libraries that NetBeans added automatically, when created Web Service Client reference and replace them with the libraries from GlassFish application server.

To those, who need step-by-step instructions:
  1. In NetBeans IDE, right-click on the client project and select "Properties". "Project Properties" dialog appears.
  2. From the "Categories" tree at the left side of the dialog, select "Libraries" item.
  3. Remove all the JAX-WS libraries—do not worry, your project is completely broken anyways. :-)
  4. On the right side of the dialog, click on "Add JAR/Folder" button. "Add JAR/Folder" dialog appears.
  5. Browse to $GLASSFISH_HOME/lib folder (and subfolders) in order to select all the libraries, listed below.
  6. Click OK.
  7. Have fun. :-)
If everything else is correctly configured (e.g. your X509 and/or SSL cert's etc) then it should work now fine. Here a full list of the libraries you want to add (some of them are in lib/endorsed subfolder):
  • activation.jar
  • appserv-deployment-client.jar
  • appserv-launch.jar
  • appserv-admin.jar
  • appserv-ext.jar
  • appserv-rt.jar
  • javaee.jar (oh my...)
  • webservices-rt.jar
  • webservices-tools.jar
  • webservices-api.jar
It will eat you 34 megabytes of disk space and 40 megabytes when running. While it looks fat, still I am much more satisfied using Swing over Java Web Start (JNLP) rather than use web browser based DHTML pages (current buzzword for DHTML now is "Ajax"). Ajax UI "eats" much more memory actually. It is significant performance problem on the Enterprise, when terminal servers for lots of users are in use.

No comments: