Welcome Guest!
Create Account | Login
Locator+ Code:

Search:
FTPOnline Channels Conferences Resources Hot Topics Partner Sites Magazines About FTP RSS 2.0 Feed

Free Subscription to Java Pro

email article
printer friendly
get the code
more resources

Write a Web Service Client
Employ Sun's JAX-RPC SI toolkit to write a client component for your organization's Web services
by Kevin Jones

December 10, 2004

Web services are emerging as a standard for building client-server applications, and you can use a variety of techniques to write them, including using toolkits. Among the toolkits available for Java are the open source Axis and the JAX-RPC standard implementation written by Sun Microsystems (see Resources).

ADVERTISEMENT

We'll focus on a step-by-step approach to writing Web service clients using Sun's JAX-RPC standard implementation (JAX-RPC SI) as its Web service toolkit. This toolkit is solid, capable of producing Web services for deployment in a production environment; it is essentially the reference implementation for the JAX-RPC standard; and the JAX-RPC specification is widely supported. For instance, both BEA and IBM support JAX-RPC, and in fact you can deploy a Web service produced by Sun's implementation into an IBM WebSphere server. In addition, Sun's implementation tracks various other specifications, such as WS-Security, that are becoming increasingly important. You can download the source code for building a Web service client.

To write a client, you need a server to program against. Several servers are available, such as Google or eBay, but here we'll use Amazon's Web service. However, knowing the service we want to use simply isn't good enough. The fact that I know that Amazon has a Web service doesn't really get me anywhere. I need to know how to call that Web service: What operations does it support? What parameters should I pass? What return values do I get?

These questions demonstrate that to write a Web service, there must be a description of that Web service available. In traditional client/server systems, servers have a description language; for example, both DCOM and CORBA use something called Interface Definition Language (IDL). DCOM and CORBA IDLs are not the same language—that is, a CORBA client could not consume a DCOM server's IDL to describe remote services available to clients.

Describe the Service
In Web services, Web Services Description Language (WSDL) takes the place of IDL by providing a description of the Web service. WSDL is an XML grammar that is machine consumable. Code generators can read it. Humans can also read it, but it is not the easiest language to consume or to produce. A colleague of mine, Simon Horrell, is fond of saying, "WSDL is like the sun: you can't live without it, but if you stare at it for too long, you'll go blind!"

Amazon provides a Web services toolkit that you can download from the Amazon site. This toolkit provides documentation for the Amazon Web service, and it also specifies the location of the WSDL document that describes the Web service, which is also available at Amazon's site. If you open this WSDL document, don't be too concerned if it looks very complex (it is), but do be aware that it provides a more or less complete description of the Web service. While you don't need the Amazon toolkit, you will need a developer token, which you can also download. Amazon uses this token to track usage of the Web service and to check that the service is not being abused (see Resources).

When you write a Web service there are many approaches you can take, but they fall broadly into two categories. You can use the tools provided by the toolkit of choice to consume the WSDL and generate client-side stubs that make the call; or you can use lower-level APIs to write the Web service by hand.




Back to top













Java Pro | Visual Studio Magazine | Windows Server System Magazine
.NET Magazine | Enterprise Architect | XML & Web Services Magazine
VSLive! | Thunder Lizard Events | Discussions | Newsletters | FTP Home