Skip to Content
Java Web Services: Up and Running
book

Java Web Services: Up and Running

by Martin Kalin
February 2009
Intermediate to advanced
316 pages
9h 28m
English
O'Reilly Media, Inc.
Content preview from Java Web Services: Up and Running

Chapter 2. All About WSDLs

What Good Is a WSDL?

The usefulness of WSDLs, the service contracts for SOAP-based web services, is shown best through examples. The original Java client against the TimeServer service invokes the Service.create method with two arguments: a URL, which provides the endpoint at which the service can be accessed, and an XML-qualified name (a Java QName), which in turn consists of the service’s local name (in this case, TimeServerImplService) and a namespace identifier (in this case, the URI http://ts.ch01/). Here is the relevant code without the comments:

URL url = new URL("http://localhost:9876/ts?wsdl");
QName qname = new QName("http://ts.ch01/", "TimeServerImplService");
Service service = Service.create(url, qname);

Note that the automatically generated namespace URI inverts the package name of the service implementation bean (SIB), ch01.ts.TimeServerImpl. The package ch01.ts becomes ts.ch01 in the URI. This detail is critical. If the first argument to the QName constructor is changed to the URI http://ch01.ts/, the Java TimeClient throws a exception, complaining that the service’s automatically generated WSDL does not describe a service with this namespace URI. The programmer must figure out the namespace URI—presumably by inspecting the WSDL! By the way, even the trailing slash in the URI is critical. The URI http://ts.ch01, with a slash missing at the end, causes the same exception as does http://ch01.ts/, with ch01 and ts in the wrong order.

The same point ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Java Web Services in a Nutshell

Java Web Services in a Nutshell

Kim Topley
SOA with Java: Realizing Service-Orientation with Java Technologies

SOA with Java: Realizing Service-Orientation with Java Technologies

Thomas Erl, Andre Tost, Satadru Roy, Philip Thomas, Raj Balasubramanian, David Chou, Thomas Plunkett

Publisher Resources

ISBN: 9780596157708Errata Page