axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jan Alexander" <a...@systinet.com>
Subject Re: Philosophical question about WSDL and web service frameworks
Date Wed, 16 Jan 2002 18:21:46 GMT
Hi James,

please see my comments inline.

Jan

Jan Alexander
WASP Server Project Leader, Systinet (formerly Idoox)
http://www.systinet.com


>
>
> -----Original Message-----
> From: James Yegerlehner [mailto:james@kamiak.com]
> Sent: Monday, January 14, 2002 11:22 PM
> To: axis-dev@xml.apache.org
> Cc: jsr-101-comments@jcp.org
> Subject: Re: Philosophical question about WSDL and web service
frameworks
>

....

>
> Jan proposed:
> > public class OrderResponseHeader
> > {
> >   ...
> >   public class Choice1
> >   {
> >       public static int DISC_ORDERHEADER = 1;
> >       public static int DISC_CHANGEORDERHEADER = 2;
> >
> >         public int discriminator;
> >
> >         public OrderHeader originalOrderHeader;
> >       public ChangeOrderHeader changeOrderHeader;
> >   }
> >
> >    ...
> >}
> >Any comments ?
>
> OK that works. I have several reservations about this:
> 1. There's nothing in the syntax that enforces the semantics. That is,
what
> is there to tell the naive user of the code that at most one of
orderHeader
> and changeOrderHeader is non-null?  I suppose he'd learn (perhaps the
hard
> way) that if the class name is "ChoiceN" then that's the situation.
But I
> think it would be better if the mutual exclusivity of the composited
> instances was enforced in the class structure.

There is a little problem, how to enforce this using Java programming
language, because it lacks union construct type, which is exactly what
is needed here. Some solution will be to inherit both OrderHeader and
ChangeOrderHeader from common ancestor, but this will not work, when
these classes are later used in another choice element together with
different XML Schema types and Java has only single inheritance for
classes. Maybe simpler way is to put inside the Choice1 class field with
type java.lang.Object, but then you will lose the nice type control,
because JVM will allow you to assign anything to this field, not only
two legal types, as is described in the XML Schema.

If you look at the mapping of Corba IDL union type to Java, you will
find very similar mapping as the proposed mapping here. You must check
the discriminator (probably in the switch statement) and choose the
proper field.

> 2. The discriminator seems superfluous in that one could just as
easily test
> for non-null as compare the discriminator integer to the enumerated
values.

The discriminator can be used inside the switch statement, without it
you must use sequence of if/then/else statements which is not so
optimal. Additionally, when the discriminator is used, all other fields
may not be null, it is enough to say, that their value is undefined.

> 3. It doesn't round-trip. That is, is there anything in this class to
tell
> the WSDL generator that it should emit a choice compositor here as
opposed
> to anything else (sequence).  I suppose there are a lot of things in
> schema-to-java mappings that are "lossy" so perhaps that's not worth
> dwelling on.

I've omitted this field from the OrdersReponseHeader class in sake of
clarity, there should be a field
    Choice1[] choice1Array;
inside this class.

Of course this does not offer same semantics as the XML Schema minOccurs
and maxOccurs, but this can be done either using javadoc extensions
(like Sun's @deprecated attribute) or by generating some constants to
the class.

> 4. Presumably you'd have to do something different if maxOccurs was >1
on
> OrderHeader, e.g.:
>
>    <element type="OrderHeader" name="OriginalOrderHeader"
maxOccurs=6/>
>
> In this case, would you emit an "OrderHeader[] originalOrderHeader"?

Yes, plus either the javadoc or constants say min and max occurences
allowed. The validation must be then done at runtime, that the message
instance is conformant to these restrictions.

>
> I don't suppose any of those concerns is a show-stopper.
>

I believe too.



Mime
View raw message