Resurrecting this from a couple days ago...
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
<service>
uses one?
I basically just want to know whether it's sufficient for me to
declare
String[]s in my .wsdl without having to declare them a second time in
my
server-config.wsdd file.
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
<s:element name="GetArrayOfSingleResult">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="unbounded"
name="floatItem" type="s:float" />
</s:sequence>
</s:complexType>
</s:element>
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:
<soapenv:Body>
<GetArrayOfSingleResponse xmlns="urn:ionic.basics.nowrapper.2005.03">
<GetArrayOfSingleReturn soapenc:arrayType="xsd:float[4]"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
<item xmlns="">0.58614534</item>
<item xmlns="">0.6191111</item>
<item xmlns="">0.6607646</item>
<item xmlns="">0.00925833</item>
</GetArrayOfSingleReturn>
</GetArrayOfSingleResponse>
</soapenv:Body>
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
<s:element name="GetArrayOfSingleResult">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="floatItem"
type="s0:Array_float" />
</s:sequence>
</s:complexType>
</s:element>
<!-- this WSDL artifact is not WS-I BP1.0 compliant, but is
necessary to enable AXIS to serialize properly -->
<s:complexType name="Array_float">
<s:sequence>
<s:element minOccurs="0" maxOccurs="unbounded" name="item"
type="s:float" />
</s:sequence>
</s:complexType>
Then, interop works. The XML on the wire looks like this:
<soapenv:Body>
<GetArrayOfSingleResponse xmlns="http://example.org/webservices/">
<GetArrayOfSingleReturn>
<item>0.1324557</item>
<item>0.46750873</item>
</GetArrayOfSingleReturn>
</GetArrayOfSingleResponse>
</soapenv:Body>
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).
http://dinoch.dyndns.org:7070/axis1.2/AboutArrays.jsp
-Dino
------------------------------------------------------------------------
--------
Laran says:
The only thing I found in the archives was Patrick Van Kann's issues
with
serializing Collections.
I basically just want to know whether it's sufficient for me to
declare
String[]s in my .wsdl without having to declare them a second time in
my
server-config.wsdd file.
Thanks.
-----Original Message-----
From: Eugene Shershnev [mailto:[EMAIL PROTECTED]]
Sent: Friday, February 25, 2005 1:19 PM
To: axis-user@ws.apache.org
Subject: Re: Array serialization-deserialization
Search the list for this. Recently there was a few discussions about
array
(de)serialization.
----- Original Message -----
From: "Laran Evans" <[EMAIL PROTECTED]>
To: <axis-user@ws.apache.org>
Sent: Friday, February 25, 2005 1:10p
Subject: Array serialization-deserialization
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
<service>
uses
one?
Thanks