Wednesday, October 6, 2010

Java Web Services with Java6 SE

Web Service is the modern buzzword. Do you really need it? Classic answer is of course "depend on your business need." It is like some sort of Remote Procedure Call.. The idea is nothing new.

You may be daunted if you attempt to open a book or read on the web about this. There is a sea of SOAP, WSDL, libraries and XML madness to read about, and some resources may tell you to download additional SDK. It is changing so fast, what you are reading may be superseded by another thing. What used to be hard may now be easier.

The real problem is that some of the stuff you see don't compile, or that EXE that you are supposed to run is not even there?
You are out of luck if you don't have someone to ask.

Here is what I want to do: create a web service for fun, without NetBeans, Glassfish, without a specific IDE or a specific server. I prefer things done in pure Notepad and Tomcat as my server if needed.

Theoretically, Java 6 makes webservice easy. Just use annotation to mark a WebService and voila. See here for official tutorial. I have JDK1.6 SE downloaded and it has all the ingredients I need to build a simple web service.

Yea, I compiled that CircleFunctions WebService, and I used "wsgen" to generate the web service. and even without tomcat, that WSDL thing does show my webservice deployed locally.

Ok, how do I test it with a client? Boom, it tells you to use NetBeans, come on.

Here is another tutorial.

Oh, to write a client the service needs to be "wsimport" first. This thing would generate a bunch of classes including a "Service" class that you can get the "Port" so you can invoke the methods.

Opinion: THIS IS NOT EASY ENOUGH. Should be simply load it up and call like regular methods. (EJB2 is even more stupid in invoking methods, but that's an ugly past)

I'll let you experient with it to see if you can create a service and call it. Do you agree that such tutorials can be written a little bit more clearer, better with downloadable code? I am not doing web services with objects yet, will try when I get more time.

Another note, around a year ago, I attempted Axis2 with some success.

No comments: