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/10/30 05:31:15 UTC
.NET interoperability problem with arrays of "primitives"
Since updating to Axis 1.0, my .NET client no longer understands the way axis sends arrays which are bean properties.
For example, I have a WSMap class that contains two String arrays, one called "Keys" and the other called "Values".
Over the wire, axis sends an object of this class like this:
<multiRef id="id4" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns3:WSMap" xmlns:ns3="urn:myproject" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
<Keys xsi:type="xsd:string">K1</Keys>
<Keys xsi:type="xsd:string">K2</Keys>
<Keys xsi:type="xsd:string">K3</Keys>
<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>
When .NET tries to deserialize this, it generates an exception like this:
Unhandled Exception: System.InvalidOperationException: There is an error in XML document (14, 41). ---> System.InvalidCastException: Cannot assign object of type System.String to an object of type System.String[].
(This is pointing to the first <Keys> element)
Does the problem lie with AXIS sending the data in a non-standard way, or with .NET not supporting the standard?
In Axis beta2 it was sent like this, which .NET understood fine:
<multiRef id="id4" SOAP-ENC:root="0" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns3:WSMap" xmlns:ns3="urn:myproject">
<Keys xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:string[3]">
<item>K1</item>
<item>K2</item>
<item>K3</item>
</Keys>
<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>
Is there any way to make Axis 1.0 use the old style?
Empty arrays not serialized properly
Posted by Martin Jericho <ma...@jabmail.com>.
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?
Re: .NET interoperability problem with arrays of "primitives"
Posted by Martin Jericho <ma...@jabmail.com>.
I just realised this happens with any array type, not just "primitives". It is probably also related to another problem I am having, which I have posted under the subject "Empty arrays not serialized properly"
----- Original Message -----
From: Martin Jericho
To: axis-user@xml.apache.org
Sent: Wednesday, October 30, 2002 2:31 PM
Subject: .NET interoperability problem with arrays of "primitives"
Since updating to Axis 1.0, my .NET client no longer understands the way axis sends arrays which are bean properties.
For example, I have a WSMap class that contains two String arrays, one called "Keys" and the other called "Values".
Over the wire, axis sends an object of this class like this:
<multiRef id="id4" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns3:WSMap" xmlns:ns3="urn:myproject" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
<Keys xsi:type="xsd:string">K1</Keys>
<Keys xsi:type="xsd:string">K2</Keys>
<Keys xsi:type="xsd:string">K3</Keys>
<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>
When .NET tries to deserialize this, it generates an exception like this:
Unhandled Exception: System.InvalidOperationException: There is an error in XML document (14, 41). ---> System.InvalidCastException: Cannot assign object of type System.String to an object of type System.String[].
(This is pointing to the first <Keys> element)
Does the problem lie with AXIS sending the data in a non-standard way, or with .NET not supporting the standard?
In Axis beta2 it was sent like this, which .NET understood fine:
<multiRef id="id4" SOAP-ENC:root="0" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns3:WSMap" xmlns:ns3="urn:myproject">
<Keys xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:string[3]">
<item>K1</item>
<item>K2</item>
<item>K3</item>
</Keys>
<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>
Is there any way to make Axis 1.0 use the old style?