users@glassfish.java.net

Re: Publishing a web API using glassfish, is there an easy way?

From: <glassfish_at_javadesktop.org>
Date: Mon, 29 Sep 2008 21:42:31 PDT

Believe it or not, SOAP is the big winner here for you. It pretty much does what you want to do.

Is it complicated? Yes, it CAN be. But if you're looking to do simple things, then SOAP is simple (well, simple enough), particularly in Glassfish.

SOAP suffers from several things. It's biggest problem is simply that it has been moving SO fast in the past several years. By the time folks implement and agree on one aspect, they're adding more to it.

Even worse, they're learning from their mistakes and changing some things as the usage moved forward. Then, there was the interoperability between systems and platforms. That got a whole mess of other people involved.

What you end up with is a flurry of information (as you discovered), and no sense of what's right, what's wrong, or which way is up.

Today, there's a final piece of the puzzle that fallen in to place to help you out, and that's all of the new tooling, particularly that in JAX-WS and within Glassfish.

With JAX-WS, you can practically simply add @WebService to the top of your Session Bean, and be done. As a developer, it doesn't get any simpler than that. The container does all of the heavy lifting for you there. Your only task is being aware of the limitations that your API must fall under to be publishable as a Web Service.

What's interesting is that if you wanted to publish your API via a Remote EJB reference, we wouldn't be having this discussion -- you'd just do it. You wouldn't worry so much about what the payload looks like, etc., you'd just publish it and some sample code to talk to it leave it, leaving the actual implementation pretty much opaque.

Web Services are almost to that point now as well. Add @WebService, and be done with it.

Mind it's not quite that rosey, there's always going to be some issues, but it's MOSTLY that rosey.

With an IDE like NetBeans, you can have a client created in 5 minutes to talk to your web service. IT deals with a lot of the arcane things, like the new vocabulary. I certainly feel your pain there.

The other alternative is to simply code up your API as a web app, or using one of the new REST frameworks (like Jersey). But, for getting an API published, those are going to be more work compared to JAX-WS.

I suggest you try JAX-WS and see how well it works for you. Don't deep dive and try to "understand" it, just try and use it -- use it as simply as you can (like let it default everything, etc.). Then, use an IDE to generate a client to talk to your API, and work with that.

This gets you familiar with it, gets your hands dirty. You'll note that the client can be a bit awkward to work with, but it is workable, and it's more the limitations of the medium than anything else.

And, as you run in to issues, chime in back here or, the Metro forum.

It's a lot easier today than it was even a year or two ago, but it's still fast moving. Stable, but fast moving.
[Message sent by forum member 'whartung' (whartung)]

http://forums.java.net/jive/thread.jspa?messageID=302479