You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Martin Jericho <ma...@jabmail.com> on 2002/11/01 01:42:43 UTC

Re: Empty arrays not serialized properly

Thanks for the tip, it has given me further insight into the problem.

Your suggestion works, but it introduces another problem.  Specifying the
beans in this way means that Java2WSDL will give the element the name
"values" instead of what I want, which is "Values" with the first letter
capitalised.  I would have to rewrite all of my .NET client code, which is
not possible.  I also prefer using the public member way of declaring the
bean's contents because it is more succinct, easier to read and maintain,
and doesn't require any superfluous implementation code that is never used
anyway.

Is there any way I can get the element names to start with capital letters
if I declare them using bean methods?

So the fundamental cause of the problem is that Java2WSDL is declaring the
array as follows if it is defined using a public member:

  <complexType name="MyClass">
    <sequence>
     <element maxOccurs="unbounded" name="Values" nillable="true"
type="xsd:string"/>
    </sequence>
   </complexType>


This is defining a repeating string element called Values, which is not the
same as a single array element called Values, and is therefore a bug.

The correct declaration, which is generated when the array is defined using
the bean get/set methods, is as follows:

<element name="values" nillable="true" type="impl:ArrayOf_xsd_string"/>
<complexType name="ArrayOf_xsd_string">
 <complexContent>
  <restriction base="soapenc:Array">
   <attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:string[]"/>
  </restriction>
 </complexContent>
</complexType>


I will create a new bug report for this in bugzilla.

Thanks again
Martin

----- Original Message -----
From: "Cun Yong Tan" <cy...@hotmail.com>
To: <ax...@xml.apache.org>
Sent: Friday, November 01, 2002 12:27 AM
Subject: Re: Empty arrays not serialized properly


>
> Have you tried changing your bean from:
>
> public class MyBean {
>     public String[] Values;
> }
>
> to:
>
> public class MyBean {
>     private String[] Values;
>     public String[] getValues();
>     public void setValues(String[] x);
> }
>
> to see if it makes a difference ?
>
>
> >From: "Martin Jericho" <ma...@jabmail.com>
> >Reply-To: axis-user@xml.apache.org
> >To: <ax...@xml.apache.org>
> >Subject: Empty arrays not serialized properly
> >Date: Thu, 31 Oct 2002 11:02:09 +1000
> >
> >Using Axis 1.0, a bean containing an array property is serialized by
simply
> >including each element of the array directly under the bean element, as
> >demonstrated in this example:
> >
> >public class MyBean {
> >     public String[] Values;
> >}
> >
> >Which looks like this over the wire:
> >
> >
> >   <multiRef id="id4" soapenc:root="0"
> >soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
> >xsi:type="ns3:MyBean" xmlns:ns3="urn:myproject"
> >xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
> >    <Values xsi:type="xsd:string">Value 1</Values>
> >    <Values xsi:type="xsd:string">Value 2</Values>
> >    <Values xsi:type="xsd:string">Value 3</Values>
> >   </multiRef>
> >
> >
> >I'm still not sure whether this is compliant with the standard (can
anyone
> >confirm this?)
> >Anyway, when the Values array is empty, there is no way to distinguish it
> >from the case where the Values field is null.  Thus, when an empty array
is
> >sent, the other side receives a null.  Here is an example of the
serialized
> >object:
> >
> >   <multiRef id="id4" soapenc:root="0"
> >soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
> >xsi:type="ns3:MyBean" xmlns:ns3="urn:myproject"
> >xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" />
> >
> >
> >To make things worse, it was acutally working properly in beta2, it is
only
> >broken in 1.0.  This is how beta2 was serializing arrays:
> >
> >   <multiRef id="id4" SOAP-ENC:root="0"
> >encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
> >xsi:type="ns3:MyBean" xmlns:ns3="urn:myproject">
> >
> >    <Values xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:string[3]">
> >     <item>Value 1</item>
> >     <item>Value 2</item>
> >     <item>Value 3</item>
> >    </Values>
> >   </multiRef>
> >
> >
> >There are two possible explanations:
> >
> >1.  This method of serializing array properties in beans is invalid.
.NET
> >doesn't understand it, which gives me some suspicions that this is the
> >case.  If so however, why was it changed since axis beta2, which was
> >serializing them in an unambiguous way that .NET understands?
> >
> >2.  This method of serializing array properties in beans is valid, but
the
> >null case should be handled differently.  This implies that .NET has a
> >problem with the standard, but there is still a bug in axis because it's
> >not handling the null case properly.
> >
> >
> >Why was this change made to axis between beta2 and 1.0?  Why wasn't it
> >properly tested?
> >
>
>
> _________________________________________________________________
> Choose an Internet access plan right for you -- try MSN!
> http://resourcecenter.msn.com/access/plans/default.asp
>
>


Re: Empty arrays not serialized properly

Posted by Steve Loughran <st...@iseran.com>.
----- Original Message -----
From: "Martin Jericho" <ma...@jabmail.com>
To: <ax...@xml.apache.org>
Sent: Sunday, November 03, 2002 14:55
Subject: Re: Empty arrays not serialized properly


> I was actually intending to get .NET to generate my WSDL for me, rather
than
> waiting for axis to get fixed.  The last thing I want to do is get
involved
> with even more beta software.  I haven't tried generating WSDL using .NET
> yet, but so far everything has worked beautifully, first time, and much
more
> intuitively than anything I've used for quite a while.  Viva Signore
Gates!
> (oops, I could get shot for that around here!)

No, I wont disagree, .net makes it easy to export stuff as web service.
There are still lots of issues with IIS/.net in terms of making a secure,
robust, scaleable, logging, LDAP configured web service, but those are
details. You do need to understand enough WSDL to know what to remove (the
non-soap HTTP bindings)

I've been hand coding WSDL the last couple of days; I finally reached the
limits of capeclear with a switch from rpc/enc to doc/lit.

-steve


Re: Empty arrays not serialized properly

Posted by Martin Jericho <ma...@jabmail.com>.
I was actually intending to get .NET to generate my WSDL for me, rather than
waiting for axis to get fixed.  The last thing I want to do is get involved
with even more beta software.  I haven't tried generating WSDL using .NET
yet, but so far everything has worked beautifully, first time, and much more
intuitively than anything I've used for quite a while.  Viva Signore Gates!
(oops, I could get shot for that around here!)

----- Original Message -----
From: "Steve Loughran" <st...@iseran.com>
To: <ax...@xml.apache.org>
Sent: Saturday, November 02, 2002 5:18 AM
Subject: Re: Empty arrays not serialized properly


>
> ----- Original Message -----
> From: "Martin Jericho" <ma...@jabmail.com>
> To: <ax...@xml.apache.org>
> Sent: Thursday, October 31, 2002 4:42 PM
> Subject: Re: Empty arrays not serialized properly
>
>
> > Thanks for the tip, it has given me further insight into the problem.
> >
> > Your suggestion works, but it introduces another problem.  Specifying
the
> > beans in this way means that Java2WSDL will give the element the name
> > "values" instead of what I want, which is "Values" with the first letter
> > capitalised.  I would have to rewrite all of my .NET client code, which
is
> > not possible.  I also prefer using the public member way of declaring
the
> > bean's contents because it is more succinct, easier to read and
maintain,
> > and doesn't require any superfluous implementation code that is never
used
> > anyway.
> >
> > Is there any way I can get the element names to start with capital
letters
> > if I declare them using bean methods?
>
> no, because that is what the JAX-PRC rules say that Axis must do. They
made
> the naming rules, not Apache.
>
> But you have a simple workaround
>
> 1. go to capeclear.com and get the latest beta of their WSDL editor
> 2. write the WSDL you want first
> 3. use wsdl2java -server to create the wsdl from this; in Ant it looks
like
> this
>
>     <axis-wsdl2java
>       output="${build.axis.generated.dir}"
>       serverside="true"
>       skeletondeploy="true"
>       url="${test.wsdl}"
>       verbose="true"
>       testcase="true"
>       >
>         <mapping
>           namespace="http://org.example/test"
>           package="${axis.soapapi.package}" />
>         <mapping
>           namespace="http://org.example/test/dtds/test.xsd"
>           package="${axis.soapapi.package}.data" />
>     </axis-wsdl2java>
>
> Then you dont have to worry about what java2wsdl does, because you control
> the WsdL
>
>


Re: Empty arrays not serialized properly

Posted by Steve Loughran <st...@iseran.com>.
----- Original Message -----
From: "Martin Jericho" <ma...@jabmail.com>
To: <ax...@xml.apache.org>
Sent: Thursday, October 31, 2002 4:42 PM
Subject: Re: Empty arrays not serialized properly


> Thanks for the tip, it has given me further insight into the problem.
>
> Your suggestion works, but it introduces another problem.  Specifying the
> beans in this way means that Java2WSDL will give the element the name
> "values" instead of what I want, which is "Values" with the first letter
> capitalised.  I would have to rewrite all of my .NET client code, which is
> not possible.  I also prefer using the public member way of declaring the
> bean's contents because it is more succinct, easier to read and maintain,
> and doesn't require any superfluous implementation code that is never used
> anyway.
>
> Is there any way I can get the element names to start with capital letters
> if I declare them using bean methods?

no, because that is what the JAX-PRC rules say that Axis must do. They made
the naming rules, not Apache.

But you have a simple workaround

1. go to capeclear.com and get the latest beta of their WSDL editor
2. write the WSDL you want first
3. use wsdl2java -server to create the wsdl from this; in Ant it looks like
this

    <axis-wsdl2java
      output="${build.axis.generated.dir}"
      serverside="true"
      skeletondeploy="true"
      url="${test.wsdl}"
      verbose="true"
      testcase="true"
      >
        <mapping
          namespace="http://org.example/test"
          package="${axis.soapapi.package}" />
        <mapping
          namespace="http://org.example/test/dtds/test.xsd"
          package="${axis.soapapi.package}.data" />
    </axis-wsdl2java>

Then you dont have to worry about what java2wsdl does, because you control
the WsdL