How to create web services in Java (with Eclipse)

It is really very difficult for me to create a simple Hello World web service in Java. If you exclude some of the mobile mobile apps for mobile devices that I made, I'm pretty new to the Java environment.

At first I tried Axis2 and it just doesn't work out of the box. A fresh install of Eclipse, Tomcat 6.0, and Axis2. Tried a test application and it failed. You can read about it here . I came to the conclusion that Axis2 just did not work (maybe it worked). I will try to return to the installation of old versions, perhaps one of them will magically start working. I need to change some old project at work that used Axis2, so I have to stick with it. I would really like to switch to another tool.

Then I ran the Oracle article Getting Started with JAX-RPC , and I thought cool, let's try this. Well, I just managed to get angry. Having received half of the article and trying to write some simple test web services, I realized that their code examples were poorly written. Missing brackets, incorrect references, lack of explanation, etc.

First of all, the interface should not extend to the implementation. I'm right?

SunRegPort public interface implements java.rmi.Remote {

In addition, this does not exist:

import java.xml .rpc.server.ServiceLifecycle;

But it does:

import javax.xml .rpc.server.ServiceLifecycle;

Well, I don’t feel competent to criticize too much (because of my level of knowledge about this subject), but in the end I am suspicious that this article is full of JUNK and therefore I can’t follow it.

Please tell me that I'm wrong, and if anyone has any advice or a link to some How-To page that talks about web services, I would appreciate it.

Thanks.

+4
source share
5 answers

Web terminology services are rather vague. In Java, a modern and fairly simple way to do this is to annotate classes. I would recommend first, you decide if you want to implement:

  • SOAP Web Services -> look at JAX-WS
  • REST web services → see JAX-RS

Once you have chosen the "type" of web services, select the library that implements the specification.

Wikipedia entries list some of these implementations. Apache CXF (full but beast), Jersey (popular) and Restlet are very common options. I personally like JBoss implementations as well as JAX-WS.

For JAX-WS with Apache CXF, here's a quick start tutorial that looks pretty good (untested)

For JAX-RS with Jersey try this

If you have no reason for others (for example, you need to call an existing system), use REST, which is simpler and more compact.

+3
source

I would recommend you check out the CXF project on apache. It is very easy to use and should help you set up a web service.

There is a good guide to setting up Hello World.

http://cxf.apache.org/docs/a-simple-jax-ws-service.html

+1
source

If you're still interested in giving Tomcat a shot, here is a youtube tutorial on creating a simple, basic “Hello world” example using Eclipse. He leaves a lot to study; but it looks like you will at least get started.

FYI, the version of Eclipse used is a bit outdated. Therefore, some menu options may not be as follows:

http://www.youtube.com/watch?v=EOkN5IPoJVs

In addition, the meaning of “web service” may be subjective. So, to be specific; it just shows you how to get the base HTTP endpoint running on your local machine.

0
source

If you're not attached to Eclipse, give NetBeans a shot. I think this is much better for Java web services.

0
source

Web services are the most widely used examples of Service Oriented Architecture (SOA). The service contract is defined using SOAP and the Web Services Definition Language (WSDL), which is published for use by other applications.

In this article we will see how we can create a web service and a web service client in java.

http://www.opencodez.com/java/how-to-build-and-deploy-web-service-and-client-in-java.htm

0
source

All Articles