dev@jax-ws.java.net

Re: Source location information in WSDLModel

From: Vivek Pandey <Vivek.Pandey_at_Sun.COM>
Date: Tue, 10 Oct 2006 06:54:42 -0700

Thanks Kohsuke, it was really needed!

This should work fine except in case of MEX the wsdl documents are bunch
of Sources extracted from the SOAP envelope and giving line number and
system id may not mean much to the user but I guess it might be better
than what we have.

-vivek.
Kohsuke Kawaguchi wrote:
>
> Today, the error handling of the JAX-WS RI is pretty poor. All too
> often user errors result in NPEs and/or unhelpful WebServiceExceptions.
>
> Just the other day, one of the Tango developers had a mistake in his
> WSDL file, which resulted in NPE in the JAX-WS RI. Eventually he
> managed to identify the problem by using the debugger and all, but the
> point is that the lack of quality error messages is wasting people's
> time. It not only waste users' time, but it also wastes *our* time,
> because they either abandon the JAX-WS RI or they would ask us to
> trouble-shoot the problem.
>
> We cannot afford to waste our time on such things. We really need to
> be serious about putting good error messages. Even when you are in
> hurry, not writing error message might save you 1 minute now, but it
> will waste an hour later. Such trade-off doesn't make any sense.
>
>
>
> So, as the first step to improve this situation, I expanded WSDLModel
> to provide source location information for all WSDL model objects. The
> WSDLObject interface is the base interface for all interfaces defined
> in the WSDL model, and this now exposes the locator which tells you
> where the object was parsed from.
>
>> public interface WSDLObject {
>> /**
>> * Gets the source location information in the parsed WSDL.
>> *
>> * This is useful when producing error messages.
>> */
>> @NotNull
>> Locator getLocation();
>> }
>
> I also added
> com.sun.xml.ws.util.exception.LocatableWebServiceException, so that
> the rest of the code can easily report errors with line information.
>
> The following code illustrates how all of these can be put together
> into one code:
>
>> void freeze(WSDLModelImpl root) {
>> boundPortType = root.getBinding(bindingName);
>> if(boundPortType==null) {
>> throw new LocatableWebServiceException(
>> ClientMessages.UNDEFINED_BINDING(bindingName),
>> getLocation());
>> }
>> }
>
>
> Please also spend a few minutes to learn how to write messages in
> property files and use the generated constant functions to format them.
>