This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Web Services and the fly likes WSDL and QName Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Web Services
Bookmark "WSDL and QName Question" Watch "WSDL and QName Question" New topic

WSDL and QName Question

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9952


The following text is from the Java WebServices: Up and Running book:

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.

Why is the package inversion for the QName critical? I did not quite understand this. Any hints?

SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9952

Any takers?
Have you checked out Aspose?
subject: WSDL and QName Question
It's not a secret anymore!