Friday, September 26, 2008

Writing a Standalone Client For Secure Web Service

Today I was puzzled writing a standalone Java client (going to be Swing app) that "talks" to the remote server, which serves a secure Web Service. Looking around various blogs and other stuff, I made it. It even works as expected. :-) 

But I want now put it all together to make it very clear and up to date. The process is all undocumented properly and successfully allows everybody hit the wall with the forehead. Therefore, to avoid others had the same sad experience googling around for a half a day, soon I am going to make a end-to-end document with a screenshots and detail explanations.

Uugghhh... Now is Friday and 8:30PM. Maybe tomorrow...

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:
javax.xml.ws.soap.SOAPFaultException: 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.

Sunday, September 21, 2008

16 Million Of Terabytes On a Laptop

Apple did great OS! Mac OSX supports 16 million of terabytes of virtual memory on... single small laptop! I am serious. Here is the evidence:


Awesome, isn't it? :-)