Java Reference
In-Depth Information
CHAPTER 13
Accessing Web Services
I n the last chapter, you learned how to establish connections to remote resources,
such as remote web servers. While connecting to remote resources is a crucial compo-
nent of many Java ME applications, most of today's networked Java ME applications
need something more: the ability to interoperate with today's web services, the services
provided by web servers designated for machine-to-machine interaction. Web services
are an important evolution of the client/server model, and applications with clear user
interfaces that present data, such as weather, financial, and travel information, from
web services are in high demand as mobile users increasingly rely upon mobile devices
for access to products and services.
In this chapter, I show you how to use the optional J2ME Web Services Specification
specified by JSR 172 to interface the Java ME platform with the web services powering
today's applications, as well as how to accomplish the same when the J2ME Web Services
Specification isn't available. I begin with a review of the web service architecture from a
client perspective, so you'll understand how working with a web service is different from
simply pulling a remote resource over the Internet. In the process, you'll learn the three
categories of web service architecture, as well as understand how HTTP and XML play
key parts in supporting today's web services. Finally, I discuss in detail the two pieces of
the web service puzzle missing from the previous chapter: how to generate and parse
XML within a Java ME application.
Looking at a Web Service from the
Client Perspective
Most breakthroughs in computing aren't revolutionary, but rather evolutionary.
The web service is no different; at its heart, it's an application of the client/server
computing model using HTTP as a bearer protocol and a well-known language such as
XML, JavaScript Object Notation ( JSON), or YAML Ain't Markup Language (YAML) for
data representation. A full-fledged web service has three key components, as you see in
Figure 13-1:
331
 
Search WWH ::




Custom Search