This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach 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

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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: 9344


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: 9344

Any takers?
I agree. Here's the link:
subject: WSDL and QName Question
Similar Threads
SAAJ client to simple hello world method
Doubt regarding invocation of JAX-WS through java client code
JBOSS web service client doesn't work ( runtime modeler error: Wrapper class not found )
JBoss WS client exception
Exception thrown While Running a Client