Sams Teach Yourself Java™ in 24 Hours (Covering Java 7 and Android)

(singke) #1
ptg7068951

WHAT YOU’LL LEARN IN
THIS HOUR:
.Defining a Java interface
for a web service
.Applying this interface to a
Java class
.Deploying a web service on
the Internet
.Viewing a web service
contract
.Creating a web service
client

Now that the Internet is everywhere, driving millions of desktop comput-
ers, web servers, phones, videogame consoles, and other devices, the
desire to connect them all together has given rise to web services, software
that communicates with other software over HTTP, the protocol of the
Web.


One of the most exciting new features of Java is the Java API for XMLWeb
Services (JAX-WS). JAX-WSis a set of packages and classes that create
clients that make requests of web services and services that take those
requests.


JAX-WS supports web services that are implemented using the Simple
Object Access Protocol (SOAP) and Representational State Transfer (REST).
JAX-WS greatly simplifies the task of supporting these protocols. As a pro-
grammer, you create Java objects and call methods to use web services and
the rest is taken care of behind the scenes.


Defining a Service Endpoint


Interface


The first step in the creation of a JAX-WS web service is to create a Service
Endpoint Interface, a Java interface that defines the methods that clientscan
call when they’re using the web service.


The SquareRootServerweb service you are developing this hour is a serv-
ice that can handle two simple tasks:


. Calculating the square root of a number
. Displaying the current date and time


HOUR 22


Creating Web Services


with JAX-WS

Free download pdf