How does a webservice work

I am new to webservices and i want to implement webservices by using java in my eclipse project.

So can anyone tel me how to implement and creating a project please



As defined by W3C web service is a software system to support interoperable machine-to-machine interaction over a network. More elaborately a system consumes service from other software system.

Web services has two major classes:

  • REST compliant
  • arbitrary web service

To implement web service one need to choose one category on the basis of his/her requirement. Java has bunch APIS to implement web services on both category.

Requirements before implementing web service is :

  • XML
  • WSDL (web service description language)
  • SOAP protocol etc

REST based is bit easy to implement compare to other category. So it's better to start with REST complaint web services.

How web service works :

WS works as request-response paradigm , there is an entity which will request for some service to it's specific counterpart namely service provider entity. Upon request, service provider will respond with a response message. So there are two message involved hear one Request message (XML)and one Response message (XML). There are bunch of ways to achieve these. Detail can be found at web service architecture

Beginner can start with JERSEY jsr311 standard reference implementation to build RESTful web services.

Example (jersey specific):

Step One : Creating root resources

// The Java class will be hosted at the URI path "/helloworld"
   public class HelloWorldResource {

      public String getClichedMessage() {
          return "Hello World";

Step Two : Deploying

public class Main {

  private static URI getBaseURI() {
      return UriBuilder.fromUri("http://localhost/").port(8080).build();

  public static final URI BASE_URI = getBaseURI();

  protected static HttpServer startServer() throws IOException {
      System.out.println("Starting ...");
      ResourceConfig resourceConfig = new PackagesResourceConfig("com.sun.jersey.samples.helloworld.resources");
      return GrizzlyServerFactory.createHttpServer(BASE_URI, resourceConfig);

  public static void main(String[] args) throws IOException {
      HttpServer httpServer = startServer();
      System.out.println(String.format("Jersey app started with WADL available at "
              + "%sapplication.wadl\nTry out %shelloworld\nHit enter to stop it...",
              BASE_URI, BASE_URI));;


REST REFERENCE - by Roy T . Fielding

Webservice is some program interface, which uses SOAP protocol for communication. Using soap, you can communicate with any program, no matter on which language it is written.

SOAP is an XML-based communication protocol and encoding format for inter-application communication. Originally conceived by Microsoft and Userland software, it has evolved through several generations; the current spec is version, SOAP 1.2, though version 1.1 is more widespread. The W3C's XML Protocol working group is in charge of the specification. SOAP is widely viewed as the backbone to a new generation of cross-platform cross-language distributed computing applications, termed Web Services.

Here is some examples:

Java web services tutorial

Axis - One of ASF implementations

CXF (Previously known as "XFire")

One of the easiest and best ways is to develop webservice using Apache Axis. Eclipse SOA toolkit supports Axis.

More information regarding sample project can be found here!

Need Your Help

Debugging multiple files in DrRacket

debugging scheme racket

I am using DrRacket to debug scheme code using the R5RS language. I am trying to debug over multiple files imported using the load function. I opened both files as the instructions on the Dr Racket

Access photos uploaded from mobile facebook graph api

javascript jquery facebook facebook-graph-api

I cannot access photos uploaded from facebook mobile application, i have "user_photos" permission, when i call album api it gets me the Mobile upload album but when i try to access photos of this a...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.