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