Re: When to use undocumented wsdl2java --wrapArrays?

2005-11-14 Thread Jarmo Doc
Hi Dims, again I don't really have an issue with Axis here.  You guys are 
doing your best to implement complex code that, in my opinion, you shouldn't 
even have to implement -- WSDL could, and should, be so much simpler than it 
is.


Keep up the good work, we all appreciate it greatly.



From: Davanum Srinivas <[EMAIL PROTECTED]>
Reply-To: [EMAIL PROTECTED]
To: axis-user@ws.apache.org
Subject: Re: When to use undocumented wsdl2java --wrapArrays?
Date: Sat, 12 Nov 2005 21:23:14 -0500

Jarmo,

Please go thru the old commits. It's a hairy situation trying to
support all kinds of stuff. Yes, if we get support from you all in
terms of patches, we can do things better. Please remember this is a
open source, volunteer project :(

http://marc.theaimsgroup.com/?l=axis-dev&w=2&r=1&s=unwrapArrays&q=b
http://marc.theaimsgroup.com/?l=axis-dev&w=2&r=1&s=wrapArrays&q=b

thanks,
dims


_
Express yourself instantly with MSN Messenger! Download today - it's FREE! 
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/




Re: When to use undocumented wsdl2java --wrapArrays?

2005-11-12 Thread Davanum Srinivas
Jarmo,

Please go thru the old commits. It's a hairy situation trying to
support all kinds of stuff. Yes, if we get support from you all in
terms of patches, we can do things better. Please remember this is a
open source, volunteer project :(

http://marc.theaimsgroup.com/?l=axis-dev&w=2&r=1&s=unwrapArrays&q=b
http://marc.theaimsgroup.com/?l=axis-dev&w=2&r=1&s=wrapArrays&q=b

thanks,
dims

On 11/10/05, Pete Hendry <[EMAIL PROTECTED]> wrote:
>
>
> >>-Original Message-
> >>From: Jarmo Doc [mailto:[EMAIL PROTECTED]
> >>Sent: Thursday, 10 November 2005 5:52 p.m.
> >>To: axis-user@ws.apache.org
> >>Subject: RE: When to use undocumented wsdl2java --wrapArrays?
> >>
> >>Thanks for the comprehensive answer Pete.
> >>
> >>Having switched to using wrapped arrays (and changing server
> >>code, client
> >>code, and WSDL!) my code now works.  I was surprised to find
> >>that I had to
> >>change the server-side code so that each class contained an
> >>ArrayOfXXX
> >>rather than XXX [].  Without this (seemingly unnecessary) layer of
> >>indirection I couldn't get the code to work at all.  For
> >>example: using
> >>simple document/literal rather than wrapped caused me to lose
> >>all 2nd and
> >>subsequent parameters to all my operations.
> >>
>
> This is an issue with Axis. I believe .NET and others (including ours)
> recognize a wrapped array and map to [] accordingly without the wrapping
> Java class. This is obviously a drawback which may want you to try to get it
> working without wrapping if that makes the code easier.
>
> >>Who would specify an interface where this kind of mess
> >>was even a
> >>possibility never mind a likelihood?  If you want to surround
> >>arrays with
> >> ...  or something else then that's fine but
> >>surely you don't
> >>have to involve me (and my server-side code, client-side
> >>code, and WSDL!) in
> >>the decision.  We've had arrays since about the Stone Age so
> >>it's not as if
> >>the people specifying these interfaces didn't know about them.
> >>
>
> There is, unfortunately, a number of areas in schema that map poorly to some
> (all in some cases) programming languages, or present alternatives (such as
> arrays) which each have different benefits/drawbacks. Don't hold your breath
> for this to be resolved as schema 1.1 is not touching on these problems I
> don't believe.
>
> Pete
>
>


--
Davanum Srinivas : http://wso2.com/blogs/


RE: When to use undocumented wsdl2java --wrapArrays?

2005-11-09 Thread Pete Hendry
 

>>-Original Message-
>>From: Jarmo Doc [mailto:[EMAIL PROTECTED] 
>>Sent: Thursday, 10 November 2005 5:52 p.m.
>>To: axis-user@ws.apache.org
>>Subject: RE: When to use undocumented wsdl2java --wrapArrays?
>>
>>Thanks for the comprehensive answer Pete.
>>
>>Having switched to using wrapped arrays (and changing server 
>>code, client 
>>code, and WSDL!) my code now works.  I was surprised to find 
>>that I had to 
>>change the server-side code so that each class contained an 
>>ArrayOfXXX 
>>rather than XXX [].  Without this (seemingly unnecessary) layer of 
>>indirection I couldn't get the code to work at all.  For 
>>example: using 
>>simple document/literal rather than wrapped caused me to lose 
>>all 2nd and 
>>subsequent parameters to all my operations.
>>

This is an issue with Axis. I believe .NET and others (including ours)
recognize a wrapped array and map to [] accordingly without the wrapping
Java class. This is obviously a drawback which may want you to try to get it
working without wrapping if that makes the code easier.

>>Who would specify an interface where this kind of mess 
>>was even a 
>>possibility never mind a likelihood?  If you want to surround 
>>arrays with 
>> ...  or something else then that's fine but 
>>surely you don't 
>>have to involve me (and my server-side code, client-side 
>>code, and WSDL!) in 
>>the decision.  We've had arrays since about the Stone Age so 
>>it's not as if 
>>the people specifying these interfaces didn't know about them.
>>

There is, unfortunately, a number of areas in schema that map poorly to some
(all in some cases) programming languages, or present alternatives (such as
arrays) which each have different benefits/drawbacks. Don't hold your breath
for this to be resolved as schema 1.1 is not touching on these problems I
don't believe.

Pete



RE: When to use undocumented wsdl2java --wrapArrays?

2005-11-09 Thread Jarmo Doc

Thanks for the comprehensive answer Pete.

Having switched to using wrapped arrays (and changing server code, client 
code, and WSDL!) my code now works.  I was surprised to find that I had to 
change the server-side code so that each class contained an ArrayOfXXX 
rather than XXX [].  Without this (seemingly unnecessary) layer of 
indirection I couldn't get the code to work at all.  For example: using 
simple document/literal rather than wrapped caused me to lose all 2nd and 
subsequent parameters to all my operations.


Who would specify an interface where this kind of mess was even a 
possibility never mind a likelihood?  If you want to surround arrays with 
 ...  or something else then that's fine but surely you don't 
have to involve me (and my server-side code, client-side code, and WSDL!) in 
the decision.  We've had arrays since about the Stone Age so it's not as if 
the people specifying these interfaces didn't know about them.


That said, I appreciate your answer.  Very helpful.



From: "Pete Hendry" <[EMAIL PROTECTED]>
Reply-To: axis-user@ws.apache.org
To: 
CC: <[EMAIL PROTECTED]>
Subject: RE: When to use undocumented wsdl2java --wrapArrays?
Date: Thu, 10 Nov 2005 16:58:34 +1300

[snip long & useful post]


_
FREE pop-up blocking with the new MSN Toolbar – get it now! 
http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/




RE: When to use undocumented wsdl2java --wrapArrays?

2005-11-09 Thread Pete Hendry
Cross-posted to soapbuilders for input from the pros :-)

>>From: Jarmo Doc [mailto:[EMAIL PROTECTED] 
>>Subject: When to use undocumented wsdl2java --wrapArrays?
>>
>>I note that Axis 1.3 wsdl2java supports an undocumented option: 
>>--wrapArrays.  I can see that it causes MyClass [] to be wrapped as 
>>ArrayOfMyClass.
>>
>>When would it be sensible to use this option?  I don't see 
>>how wrapping an 
>>array of trivial things in another class serves any useful purpose.
>>

Here is something I wrote in reply to a question in-house recently. If
anyone disagrees or has an opinion on this (or I've made any mistakes, or
it's just plain wrong!) I'd like to hear it as it is being written up for
our documentation.

In the past there have been some issues around minOccurs="0" and
nillable="true" for array elements. This was an attempt to clear this up
(even where "clearing it up" means pointing out the unresolvable ambiguity
with unwrapped arrays).

--

Arrays may be written in 2 ways which result in slightly different XML. One
way is to wrap the array elements in an outer element which means there is a
single array element which maps to the Java field with an array type. To
show the 2 mappings consider the simple class

public class Test {
   public int id;
   public String[] names;
   public String city;
}

This may be mapped with wrapped arrays as follows









   
  
   


which would lead to an XML document such as


   10
   
  John
  Henry
  Ford
   
   Boston


Here it is clear to see that the  element maps to the "names" Java
field in the Test class. There are other advantages listed later. The
alternative "unwrapped" array approach defines the Test type as









leading to XML such as


   10
   John
   Henry
   Ford
   Boston


Here the  elements are at the same level as the other field elements.
Also, the names element are each plural which is not a good mapping as each
should be singular. To fix the pluralization (and perhaps a more natural
schema) you could change this to









leading to XML such as


   10
   John
   Henry
   Ford
   Boston


but then there is not a mapping between

String[] names

and 

 

Use of wrapped maps more naturally to object languages. It makes naming the
elements clearer (as the above shows, you can have "String[] names" and
muliple elements called "names" or "String[] name" and multiple elements
named "name" - neither is "correct"), it maps directly from schema element
to Java field, and finally it allows differentiating between a null value of
the array reference and an empty array which is not possible with the
unwrapped approach.

Consider the unwrapped definition with respect to both a null array
reference, null array values and an empty array and the following XML
fragments

Fragment 1a

   10
   
   Boston


Fragment 1b

   10
   Boston


Mapping Fragment 1a to Java maps (surprisingly to some) to

Test[
   id = 10
   names = { null }
   city = 'Boston"
]

Note that "names" is a 1 element array with the names[0] being the null
value.

Fragment 1b has an unresolvable ambiguity. Does the absence of a recurring
value map to the empty array or the null value? Is fragment 1b equivalent to

Test[
   id = 10
   names = null
   city = "Boston"
]

or

Test[
   id = 10
   names = { }
   city = "Boston"
]

The answer is that this depends on the toolkit. This is an either/or
situation as there is no way to use "nillable" to indicate a null array
reference.

With a wrapped array the situation is a little different because of the
extra level of indirection. The outer element may be used to indicate the
null value while the inner elements are used to indicate the array contents
(including no content).

Fragment 2a
 
   10
   
   Boston


Fragment 2b

   10
   
   Boston


Fragment 2c

   10
   
  
   
   Boston


In Fragment 2a, the names element is present and is nil. Because this
element maps directly to the Java field (or field of another OO language) it
is clear the intention is to pass the null value.

In Fragment 2b, the names element is present but has no content. The value
is clearly not nil and also clearly has no elements and so must map to the
empty array.

In Fragment 2c it is clear that the  element is an item within the
names array and is nil (null).

These examples clearly show that use of wrapped arrays removes the
ambiguities associated with unwrapped arrays.

Personally I recommend the use of wrapped arrays as a programmer.

Pete