Java Reference
In-Depth Information
8.1. What is a web service?
It's very difficult to arrive at a single definition of web services that all camps will agree on.
Simply put, a web service is a standard platform that provides interoperability between net-
worked applications. For most developers, this means XML messages that are transmitted
via HTTP/HTTPS. Both XML and HTTP/HTTPS are standard and pervasive in enabling
the service to be used by a multitude of different clients built with different technologies.
For example, if you build a web service using Java EE, you can invoke that client from
any number of applications—including those written in C#, Python, C++, and Objective-
C—without having to make any changes. This is shown in figure 8.1 , where web services
enable a multitude of applications to exchange data with a Java Enterprise application.
Figure 8.1. Web services provide interoperability between networked applications, like the Java EE application
and a PHP web front end.
8.1.1. Web service properties
When a web service is invoked, ultimately a method ends up handling the request and gen-
erating a response. Thinking in terms of Java methods, the parameters to the request can
be a Java primitive or an objective graph—the same is true of the response. As its name
implies, a web service is a service—that is, it performs a business operation. Examples of
web services include operations to place an order, check the status of an order, cancel an
order, and so on. A web service wouldn't be used to implement accessor/mutator methods
like setName() , setPhoneNumber() , and so on. These are too granular and web ser-
vice calls are stateless. Let's expound upon the last point: web services deal with services
and not objects. With web services there's no concept of sessions and therefore subsequent
method calls are completely independent. This is different from something like Java's RMI
where you have a proxy representing a remote object and can invoke remove methods.
Besides being stateless, web service invocations are also synchronous. A client must wait
for the web service to complete and return a response.
 
Search WWH ::




Custom Search