|
Replies:
6
-
Last Post:
Sep 22, 2009 11:08 AM
by: dobes
|
|
|
|
|
|
|
Publishing a web API using glassfish, is there an easy way?
Posted:
Sep 29, 2008 8:34 PM
|
|
|
I'd like to publish an API for my SaaS application powered by glassfish but I'm having trouble find a good library to do this with.
- I tried Apache Axis2 but after a few hours thought "there must be an easier way", but maybe I should try it again - I tried to use the @WebService annotation but the documentation is so scattered and there are so many bugs, missing features, version numbers, and ambiguous documentation that I'm just lost and confused about how to get this working; it seems to at least require that I'm an expert about SOAP, if not an expert on WSGEN and Metro with a copy of the source code open for reference. - I tried to use something called "doff" which looked cool for publishing a RESTful API but barfed when I loaded it into glassfish and it tried to do some kind of clever service discovery algorithm.
I'm not concerned about whether it's SOAP, XML-RPC, or RESTful; I'm just looking for something:
- nice and simple that - wraps my EJB interface into something accessible by HTTP - has documentation all in one place for a lay man like myself - works out of the box in the glassfish v2ur2 container - doesn't require me to modify the jars that came with glassfish (i.e. all the jars fit into the EAR) - doesn't require me to understand SOAP-specific terms like "wsdl:portType"
Has anyone run into anything along these lines - what would you recommend?
|
|
|
|
|
|
|
Re: Publishing a web API using glassfish, is there an easy way?
Posted:
Sep 29, 2008 9:42 PM
in response to: dobes
|
|
|
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.
|
|
|
|
|
|
|
|
Re: Publishing a web API using glassfish, is there an easy way?
Posted:
Sep 29, 2008 9:52 PM
in response to: whartung
|
|
|
Thanks - I've been struggling with JAX-WS trying to understand it's limitations, I suppose. After I wrote my original question I took another try at it with an extremely simplified version of my EJB - basically I create a new Local interface to implement which had just one method. It was accepted by glassfish and wsgen succeeded (yay) so perhaps all I need to do now is figure out how to configure it and which of my methods was rejected.
It seems like in order to set the URL that my web service is available at, I need this jaxrpc-ri.xml file in the WAR, even though my web service is defined in a JAR. Anyway - a lot of very bad documentation to trundle through, but I did make a bit more progress.
Where can I find out more about the restrictions on what my bean methods can look like?
And, any other good ones out there?
|
|
|
|
|
|
|
|
Re: Publishing a web API using glassfish, is there an easy way?
Posted:
Sep 29, 2008 10:33 PM
in response to: dobes
|
|
|
Nope, jaxrpc-ri.xml isn't the answer and when I tried to create a custom websrevices.xml I was rejected 
How can I change the URI of the web service? Why is something seemingly so simple being made so difficult ...
|
|
|
|
|
|
|
|
Re: Publishing a web API using glassfish, is there an easy way?
Posted:
Sep 30, 2008 2:09 PM
in response to: dobes
|
|
|
Here's what we did: Install Apache CXF (Chasing down lots of jars) Wrote an interface (in a separate package) for the service we wanted to export. Wrote an instance of the service that connected to our system. Used the JaxWsServerFactoryBean to create a server, specifying the interface as the service class (setServiceClass()). Gave the customer the javadoc for the package with the interface in it Customer wrote a NET client for it. It got us through the prototype testing, but was never deployed for political reasons (overall project went to another bidder). This isn't integrated with glassfish at all, but your service implementation could do the lookups and use whatever system you have. Not sure if this helps.
|
|
|
|
|
|
|
|
Re: Publishing a web API using glassfish, is there an easy way?
Posted:
Sep 30, 2008 8:42 PM
in response to: cobrien
|
|
|
Thanks, I hadn't seen Apache CXF yet, although I'm not sure how easy it would be to load CXF into glassfish since it looks like they'd be processing the same annotations ...
|
|
|
|
|
|
|
|
Re: Publishing a web API using glassfish, is there an easy way?
Posted:
Sep 22, 2009 11:08 AM
in response to: dobes
|
|
|
Am I trying out Apache CXF in glassfish now and, as I had suspected a year ago, glassfish is processing the same annotations. The reason I want to use CXF in this case is to try using their servlet - it seems like CXF might give me more control over various things.
Unfortunately, glassfish still runs WSGEN on the WebService. Any idea how I could tell glassfish NOT to run wsgen?
|
|
|
|
|