Posted: February 7, 2012 in Random Posts

Nikos' Java blog

We are about to create a simple Web Service in Java. The only requirement is Java SE 6.

At first, we clearly define the operation to be exposed.

public interface SimpleService {
   String sayHello();
}

Let’s declare it as a web service.

@WebService@SOAPBinding(style=Style.RPC)
public interface SimpleService {
   @WebMethod
   String sayHello();
}

API: WebService, WebMethod, SOAPBinding, SOAPBinding.Style

So we have a web service with a single operation: sayHello. Moreover we choose the simplified RPC style. Let’s implement the operation.

public class SimpleServiceImpl implements SimpleService {
   public String sayHello() {
      return "Hello from Web Services!";
   }
}

We should provide the complete name of the service interface,

@WebService(endpointInterface="simple.SimpleService")
public class SimpleServiceImpl implements SimpleService {
   public String sayHello() {
      return "Hello from Web Services!";
   }
}

where simple is the package of SimpleService.

At this point, it is easy to publish the web service locally.

 public class…

View original post 283 more words

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s