axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bill Keese <bi...@tech.beacon-it.co.jp>
Subject Re: Array serialization-deserialization
Date Fri, 04 Mar 2005 02:03:33 GMT
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Hi Dino,<br>
<blockquote type="cite">
  <pre wrap="">      &lt;!-- this WSDL artifact is not WS-I BP1.0 compliant, but
is
necessary to enable AXIS to serialize properly --&gt; 
      &lt;s:complexType name="Array_float"&gt;
  </pre>
</blockquote>
By the way, what is uncomplaint about this?&nbsp; It seems like most people
use wrapper complexTypes for their arrays.<br>
<br>
Bill<br>
<br>
Dino Chiesa wrote:
<blockquote
 cite="midC7FA36AFCE3E8D4298586892AC960E0D053C73C0@RED-MSG-32.redmond.corp.microsoft.com"
 type="cite">
  <meta http-equiv="Content-Type" content="text/html; ">
  <meta content="MSHTML 6.00.2900.2604" name="GENERATOR">
  <div align="left" dir="ltr"><span class="193494201-04032005"><font
 color="#0000ff" face="Tahoma" size="2">yes, that's what I get, too. </font></span></div>
  <br>
  <div class="OutlookMessageHeader" align="left" dir="ltr" lang="en-us">
  <hr tabindex="-1"><font face="Tahoma" size="2"><b>From:</b> Bill
Keese [<a class="moz-txt-link-freetext" href="mailto:billk@tech.beacon-it.co.jp">mailto:billk@tech.beacon-it.co.jp</a>]
<br>
  <b>Sent:</b> Thursday, March 03, 2005 7:34 PM<br>
  <b>To:</b> <a class="moz-txt-link-abbreviated" href="mailto:axis-user@ws.apache.org">axis-user@ws.apache.org</a><br>
  <b>Subject:</b> Re: Array serialization-deserialization<br>
  </font><br>
  </div>
My latest experience with this is that (with Axis 1.2, at least), you
don't have to declare arrays in your WSDD file.&nbsp; However, if you have a
wrapper class like this:<br>
  <pre>      &lt;s:complexType name="Array_float"&gt;
        &lt;s:sequence&gt;
            &lt;s:element minOccurs="0" maxOccurs="unbounded" name="item"
type="s:float" /&gt;
        &lt;/s:sequence&gt;
      &lt;/s:complexType&gt;</pre>
  <br>
... then you have to declare Array_float as a BEAN (not an Array).&nbsp;
This makes sense when you really think about although it's
counter-intuitive at first.<br>
  <br>
Anyway, if you use bare arrays like this:<br>
  <pre wrap="">      &lt;s:element name="GetArrayOfSingleResult"&gt;
        &lt;s:complexType&gt;
          &lt;s:sequence&gt;
            &lt;s:element minOccurs="0" maxOccurs="unbounded"
name="floatItem" type="s:float" /&gt;
          &lt;/s:sequence&gt;
        &lt;/s:complexType&gt;
      &lt;/s:element&gt;</pre>
... then you don't have to declare anything.<br>
  <br>
  <br>
  <br>
Dino Chiesa wrote:
  <blockquote
 cite="midC7FA36AFCE3E8D4298586892AC960E0D053C70CA@RED-MSG-32.redmond.corp.microsoft.com"
 type="cite">
    <pre wrap="">Resurrecting this from a couple days ago...

  </pre>
    <blockquote type="cite">
      <pre wrap="">Is Axis smart enough to automatically use an ArraySerializer to
serialize/deserialize arrays of simple types, a String[] for instance?

Or do I have to declare a typeMapping for String[] wherever a
    </pre>
    </blockquote>
    <pre wrap=""><!---->&lt;service&gt;
  </pre>
    <blockquote type="cite">
      <pre wrap="">uses one?
    </pre>
    </blockquote>
    <pre wrap=""><!---->
  </pre>
    <blockquote type="cite">
      <pre wrap="">I basically just want to know whether it's sufficient for me to
    </pre>
    </blockquote>
    <pre wrap=""><!---->declare
  </pre>
    <blockquote type="cite">
      <pre wrap="">String[]s in my .wsdl without having to declare them a second time
in
    </pre>
    </blockquote>
    <pre wrap=""><!---->my
  </pre>
    <blockquote type="cite">
      <pre wrap="">server-config.wsdd file.
    </pre>
    </blockquote>
    <pre wrap=""><!---->
I think the answer is 
Yes, if you use AXIS 1.2RC3, 
No, if you use AXIS 1.1. 

Using AXIS 1.1, I cannot get arrays of simple types (string float, etc)
to serialize properly without a wrapper.  I think the ArraySerializer
always uses soap encoding, which is probably not what you want. 

Suppose I define a message element in the wsdl representing an array of
a simple type, such as 

      &lt;s:element name="GetArrayOfSingleResult"&gt;
        &lt;s:complexType&gt;
          &lt;s:sequence&gt;
            &lt;s:element minOccurs="0" maxOccurs="unbounded"
name="floatItem" type="s:float" /&gt;
          &lt;/s:sequence&gt;
        &lt;/s:complexType&gt;
      &lt;/s:element&gt;

Then I run WSDL2Java --server-side , and generate the interface and the
deploy.wsdd.   If I then provide my own implementation, and deploy it
all (wrapped/literal), the response is not serialized properly.  I get: 

 &lt;soapenv:Body&gt;
  &lt;GetArrayOfSingleResponse xmlns="urn:ionic.basics.nowrapper.2005.03"&gt;
   &lt;GetArrayOfSingleReturn soapenc:arrayType="xsd:float[4]"
xmlns:soapenc=<a class="moz-txt-link-rfc2396E"
 href="http://schemas.xmlsoap.org/soap/encoding/">"http://schemas.xmlsoap.org/soap/encoding/"</a>&gt;
    &lt;item xmlns=""&gt;0.58614534&lt;/item&gt;
    &lt;item xmlns=""&gt;0.6191111&lt;/item&gt;
    &lt;item xmlns=""&gt;0.6607646&lt;/item&gt;
    &lt;item xmlns=""&gt;0.00925833&lt;/item&gt;
   &lt;/GetArrayOfSingleReturn&gt;
  &lt;/GetArrayOfSingleResponse&gt;
 &lt;/soapenv:Body&gt;

Ick.  This seems wrong since the wsdd says "doc/literal".  Also it's not
going to work for interop with .NET clients.  I didn't try it with other
clients. 

On the other hand if in the WSDL I define a complexType that wraps the
sequence of elements, such as 

      &lt;s:element name="GetArrayOfSingleResult"&gt;
        &lt;s:complexType&gt;
          &lt;s:sequence&gt;
            &lt;s:element minOccurs="0" maxOccurs="1" name="floatItem"
type="s0:Array_float" /&gt;
          &lt;/s:sequence&gt;
        &lt;/s:complexType&gt;
      &lt;/s:element&gt;

      &lt;!-- this WSDL artifact is not WS-I BP1.0 compliant, but is
necessary to enable AXIS to serialize properly --&gt; 
      &lt;s:complexType name="Array_float"&gt;
        &lt;s:sequence&gt;
            &lt;s:element minOccurs="0" maxOccurs="unbounded" name="item"
type="s:float" /&gt;
        &lt;/s:sequence&gt;
      &lt;/s:complexType&gt;

Then, interop works.  The XML on the wire looks like this: 

 &lt;soapenv:Body&gt;
  &lt;GetArrayOfSingleResponse xmlns=<a class="moz-txt-link-rfc2396E"
 href="http://example.org/webservices/">"http://example.org/webservices/"</a>&gt;
   &lt;GetArrayOfSingleReturn&gt;
    &lt;item&gt;0.1324557&lt;/item&gt;
    &lt;item&gt;0.46750873&lt;/item&gt;
   &lt;/GetArrayOfSingleReturn&gt;
  &lt;/GetArrayOfSingleResponse&gt;
 &lt;/soapenv:Body&gt;

Which is fine.  Somebody else has previously pointed out that the
element name is always Always ALWAYS "item", but that's only a minor
thing. The main drawback is that there is an extra wrapper in the
Java-side programming model.  I cannot return float[], I have to deal
with a wrapper class (bean) that has a float[] as a property.  Like so: 

  public Array_float getArrayOfSingle(...) {
   Array_float a= new Array_float();
   a.setItem(new float[n]); 
   return a; 
  }


That was all for AXIS 1.1.  I guess the wrapper type on the server side
is the price you pay for using "simple arrays".  

----

In AXIS 1.2RC3, it just works for me. 
A working example of an AXIS web service that sends Arrays of simple
types to .NET clients is here (with app source). 
<a class="moz-txt-link-freetext"
 href="http://dinoch.dyndns.org:7070/axis1.2/AboutArrays.jsp">http://dinoch.dyndns.org:7070/axis1.2/AboutArrays.jsp</a>




-Dino

------------------------------------------------------------------------
--------

Laran says:
  </pre>
    <blockquote type="cite">
      <pre wrap="">The only thing I found in the archives was Patrick Van Kann's issues
    </pre>
    </blockquote>
    <pre wrap=""><!---->with
  </pre>
    <blockquote type="cite">
      <pre wrap="">serializing Collections.

I basically just want to know whether it's sufficient for me to
    </pre>
    </blockquote>
    <pre wrap=""><!---->declare
  </pre>
    <blockquote type="cite">
      <pre wrap="">String[]s in my .wsdl without having to declare them a second time
in
    </pre>
    </blockquote>
    <pre wrap=""><!---->my
  </pre>
    <blockquote type="cite">
      <pre wrap="">server-config.wsdd file.

Thanks.

-----Original Message-----
From: Eugene Shershnev [<a class="moz-txt-link-freetext"
 href="mailto:shersh@gmail.com">mailto:shersh@gmail.com</a>] 
Sent: Friday, February 25, 2005 1:19 PM
To: <a class="moz-txt-link-abbreviated"
 href="mailto:axis-user@ws.apache.org">axis-user@ws.apache.org</a>
Subject: Re: Array serialization-deserialization

Search the list for this. Recently there was a few discussions about
    </pre>
    </blockquote>
    <pre wrap=""><!---->array
  </pre>
    <blockquote type="cite">
      <pre wrap="">(de)serialization.

----- Original Message -----
From: "Laran Evans" <a class="moz-txt-link-rfc2396E"
 href="mailto:lc278@cornell.edu">&lt;lc278@cornell.edu&gt;</a>
To: <a class="moz-txt-link-rfc2396E"
 href="mailto:axis-user@ws.apache.org">&lt;axis-user@ws.apache.org&gt;</a>
Sent: Friday, February 25, 2005 1:10p
Subject: Array serialization-deserialization


    </pre>
      <blockquote type="cite">
        <pre wrap="">Is Axis smart enough to automatically use an ArraySerializer to
serialize/deserialize arrays of simple types, a String[] for
      </pre>
      </blockquote>
    </blockquote>
    <pre wrap=""><!---->instance?
  </pre>
    <blockquote type="cite">
      <blockquote type="cite">
        <pre wrap="">Or do I have to declare a typeMapping for String[] wherever a
      </pre>
      </blockquote>
    </blockquote>
    <pre wrap=""><!---->&lt;service&gt;
  </pre>
    <blockquote type="cite">
      <pre wrap="">uses
    </pre>
      <blockquote type="cite">
        <pre wrap="">one?

Thanks


      </pre>
      </blockquote>
    </blockquote>
    <pre wrap=""><!---->

  </pre>
  </blockquote>
</blockquote>
</body>
</html>

Mime
View raw message