aspose file tools*
The moose likes Web Services and the fly likes Implementing Web Services with J2EE 1.4 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Implementing Web Services with J2EE 1.4" Watch "Implementing Web Services with J2EE 1.4" New topic
Author

Implementing Web Services with J2EE 1.4

Edmund Yong
Ranch Hand

Joined: Nov 16, 2003
Posts: 164
We have a system that is deployed on Sun Java System Application Server 8.2. I am tasked to look into developing web services to be build on the system, so that other systems can use services that our system has. I don't have any working experience with web services, and my only knowledge came from a course which I took a few years ago that taught about web services on the .NET platform. I won't have to be the one who will eventually write the web services, but I would like to about the technologies behind it, and how web services are actually written.

1. First of all, I understand that for the application server that we are using, the supported Java EE version is 1.4. This means that there is no JAX-WS 2.0. Instead there is JAX-RPC 1.1, so we would have to use JAX-RPC 1.1. Is this important at all? Next time, if the application server is to be upgraded to one that supports Java EE 5, would there be an issue?

2.. Secondly, how are web services written in Java? Does the following article describe how web services are written in practice? The article was written a few years ago, so I don't know if it is still relevant.

Developing Web Services with J2EE 1.4

3. I have also read about web services implemented with session bean, in a book about EJB 3.0. This is in contrast to implementation using servlets, as described in the article above. Does that mean that if I have EJB 3.0, I can implement the web service with session beans, but if I am using just Java EE 1.4, I have to do it as how the article above described?

Coming from a novice like me, maybe some of the questions might sound stupid to some of you. So please bear with me.

Thanks in advance.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42276
    
  64
1. First of all, I understand that for the application server that we are using, the supported Java EE version is 1.4. This means that there is no JAX-WS 2.0. Instead there is JAX-RPC 1.1, so we would have to use JAX-RPC 1.1. Is this important at all? Next time, if the application server is to be upgraded to one that supports Java EE 5, would there be an issue?

Whatever you end up doing, don't use JAX-RPC. While it is part of JEE 5, it has already been deprecated for JEE 6. So you shouldn't use it for new development. The SAAJ API is still available, although it works on a much lower level, and so isn't very pleasant to work with.

Assuming that you're using at least a Java 5 JVM you should be able to run services developed using JAX-WS and JAXB, though. (You can get the reference implementations of those from dev.java.net.) They'd be running outside of the control of the JEE server, though (which may or may not matter in your situation).

You could also look into RESTful services that will be part of JEE 6. Until then, the Jersey reference implementation of the JAX-RS API is available at dev.java.net, and quite easy to get started with. It requires Java 5 as well.

3. I have also read about web services implemented with session bean, in a book about EJB 3.0. This is in contrast to implementation using servlets, as described in the article above. Does that mean that if I have EJB 3.0, I can implement the web service with session beans, but if I am using just Java EE 1.4, I have to do it as how the article above described?

I'm fairly certain that EJB 2 session beans can also act as WS endpoints.
Alan Hampson
Ranch Hand

Joined: Apr 10, 2009
Posts: 31
You could also consider using Apache Axis2 which works with JDK 1.4 and above. It is simple to use; you create your Java class that represents the WebService and set some configuration. Then when you run Axis2 as your web application, your service gets created based on the class.

Also, be sure to consider the age of articles when researching WebServices. When I was starting out it was very confusing because the information had changed so much, even in the last year or so.

Good Luck,
alan
Edmund Yong
Ranch Hand

Joined: Nov 16, 2003
Posts: 164
Hi guys,

Thanks for the helps. Some further questions:

1. When we code a session bean as a web service, is JAX-RPC or JAX-WS being used?

2. About the Apache Axis, you mean that there would be a need for a separate web application to host the web service?. How would the web service on this web application be able to access our application, which is another web application?

Thanks.
Alan Hampson
Ranch Hand

Joined: Apr 10, 2009
Posts: 31
1. When we code a session bean as a web service, is JAX-RPC or JAX-WS being used?

I believe this would depend on what libraries you use and how you coded it. I haven't had much experience in the JAX area yet, so maybe someone more knowledgeable can correct me if I'm wrong.

2. About the Apache Axis, you mean that there would be a need for a separate web application to host the web service?. How would the web service on this web application be able to access our application, which is another web application?

Axis does run as a separate web application. In return for this, it's providing all the web service plumbing: SOAP conversion, RPC hookups, and REST access as well. I believe this is how JAX-WS works also.

As to how it would access your application, it would depend on how your current application is constructed. If it's all Java and beans, you could write some code which used the current functionality as a library. Then a call to the service would call the new code which would call the current application code.

In my case, the legacy application had very little in the way of usable code since much of it was written in Perl CGI and javascript. I had to rewrite much of the functionality above the database level and write the web service layer as well.

Much of what you read on the web is obsolete or changed because of the changes to libraries and the onset of new projects: Axis was replaced by Axis2, JAX-RPC was phased out in favor of JAX-WS, etc. What might help you the most would be to download some of the current code and work with it a bit. Then you could see how things fit together and work.

Please let me know if I can confuse you further! Really, though, let me know what other questions you have.

alan
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42276
    
  64
Axis comes as a ready-to-run web app, but in the end, it's just a servlet - you can add it to whichever web app you already have.
Alan Hampson
Ranch Hand

Joined: Apr 10, 2009
Posts: 31
Argh! Yeah, I'm not thinking. Axis2 is the same.

alan
Edmund Yong
Ranch Hand

Joined: Nov 16, 2003
Posts: 164
Thanks guys, but I think I am still as confused as before.

Ok, first, I would like to stress that we are using Sun Java System Application Server 8.2, which is based on J2EE 1.4. So we can't use JAX-WS, right?

So what really are my options? I would want to ensure that if the application service is upgrade to a Java EE 5 compliant one, the web service will still work with minimum changes.

If we use Axis2, we can use it on the current application server, and next time, when it's being upgraded, it's still no issue. Right?

Thanks.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42276
    
  64
we are using Sun Java System Application Server 8.2, which is based on J2EE 1.4. So we can't use JAX-WS, right?

Wrong. JAX-WS depends on JSE 5, not on JEE 5. As long as there's a Java 5 JRE, JAX-WS is an option.

I would want to ensure that if the application service is upgrade to a Java EE 5 compliant one, the web service will still work with minimum changes.

SAAJ is an option, as are JAX-RS and JAX-WS provided a version 5 JRE is present. JAX-RPC is also an option, although a bad one, because it's deprecated in JEE 6. So if you end up moving to JEE 6 instead of JEE 5, that may turn out to have been a bad choice.

If we use Axis2, we can use it on the current application server, and next time, when it's being upgraded, it's still no issue. Right?

Yes.
Edmund Yong
Ranch Hand

Joined: Nov 16, 2003
Posts: 164
Hi Ulf,

Actually the Sun Java System Application Server 8.2 can run on Java 5 JRE, so indeed JAX-WS is an option. But we will still need to download separate library JAR files for JAX-WS, don't we? If we were to use a JEE 5 application server instead, the JAX-WS library would be there, wouldn't it?

Thanks.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42276
    
  64
Yes, and Yes.
Edmund Yong
Ranch Hand

Joined: Nov 16, 2003
Posts: 164
Thanks again, Ulf.

By the way, is the JAX-RS Reference Implementation something that one can seriously consider for use in a real production environment?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42276
    
  64
I would, but people differ in their tolerance for the bleeding edge :-)

It's been under development for while, so the fact that 1.0 came out just 6 months ago is a bit misleading. And there have been a few fixes already, and no major problems - so that's good.

I haven't stress-tested the performance, though, so if you anticipate lots of users you'll want to do that (or check the web if others have done so). Anything SOAP-based is unlikely to be much faster due to the XML overhead, though.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Implementing Web Services with J2EE 1.4