You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-user@axis.apache.org by "Jonathan G Beakley (beakley)" <be...@cisco.com> on 2006/03/20 16:54:59 UTC
Java client array encoding causes troubles for AxisCPP service
I have noticed an inconsistency in the encoding of arrays by Axis Java
clients (created using WSDL2Java) and AxisCPP clients (created using
WSDL2Ws), and I was hoping someone could give me some advice.
In short, I have the following RPC/encoded WSDL snippet that defines the
array:
<types>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://localhost/axis/csaapi/xsd">
<import namespace = "http://schemas.xmlsoap.org/soap/encoding/"/>
<complexType name="ArrayOfInt">
<complexContent>
<restriction base="soapenc:Array">
<attribute ref="soapenc:arrayType"
wsdl:arrayType="int[]"/>
</restriction>
</complexContent>
</complexType>
</schema>
</types>
When I create and run the AxisCPP client, it generates XML that uses
"<item>" to denote the elements in the array:
<SOAP-ENV:Body>
<ns1:GetNamesByIds
xmlns:ns1="http://localhost/axis/csaapi">
<objType xsi:type="xsd:int">0</objType>
<idsArray
xmlns:enc="http://www.w3.org/2001/06/soap-encoding"
enc:arrayType="xsd:int[9]">
<item>1</item>
<item>2</item>
<item>3</item>
</idsArray>
</ns1:GetNamesByIds>
</SOAP-ENV:Body>
My AxisCPP service handles this just fine.
BUT, my Java client generates XML that doesn't use the "<item>"
construct, and it causes my CPP service to fail to parse the data.
Here's the Java XML:
<soapenv:Body>
<ns1:GetNamesByIds
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns1="http://localhost/axis/csaapi">
<objType xsi:type="xsd:int">0</objType>
<ids soapenc:arrayType="xsd:int[9]"
xsi:type="soapenc:Array"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
<ids xsi:type="xsd:int">1</ids>
<ids xsi:type="xsd:int">2</ids>
<ids xsi:type="xsd:int">3</ids>
</ids>
</ns1:GetNamesByIds>
</soapenv:Body>
Could someone give me advice on the best way to handle this? Note that
I've already turned the MULTIREF option off to fix a different set of
problems. I'd prefer to keep the RPC/Encoded style if at all possible.
Thank you very much in advance!
-Jonathan Beakley
beakley@cisco.com
Re: Java client array encoding causes troubles for AxisCPP service
Posted by Adrian Dick <ad...@uk.ibm.com>.
Hi,
Handling of arrays for rpc/encoded web services is a suprisingly complex
problem. The SOAP spec provides several different, but apparently
equivalent, techniques. One of which is that employed by Axis C++
serialiation, another of which is that used by Axis Java.
Regrettably, it would appear the AxisCPP deserializer doesn't handle all
the variations.
Can you raise a Jira issue for this, including the SOAP messages you give
below.
Regards,
Adrian
_______________________________________
Adrian Dick (adrian.dick@uk.ibm.com)
"Jonathan G Beakley \(beakley\)" <be...@cisco.com> wrote on 20/03/2006
15:54:59:
> I have noticed an inconsistency in the encoding of arrays by Axis Java
> clients (created using WSDL2Java) and AxisCPP clients (created using
> WSDL2Ws), and I was hoping someone could give me some advice.
>
> In short, I have the following RPC/encoded WSDL snippet that defines the
> array:
>
> <types>
> <schema xmlns="http://www.w3.org/2001/XMLSchema"
> targetNamespace="http://localhost/axis/csaapi/xsd">
> <import namespace = "http://schemas.xmlsoap.org/soap/encoding/"/>
> <complexType name="ArrayOfInt">
> <complexContent>
> <restriction base="soapenc:Array">
> <attribute ref="soapenc:arrayType"
> wsdl:arrayType="int[]"/>
> </restriction>
> </complexContent>
> </complexType>
> </schema>
> </types>
>
> When I create and run the AxisCPP client, it generates XML that uses
> "<item>" to denote the elements in the array:
>
> <SOAP-ENV:Body>
> <ns1:GetNamesByIds
> xmlns:ns1="http://localhost/axis/csaapi">
> <objType xsi:type="xsd:int">0</objType>
> <idsArray
> xmlns:enc="http://www.w3.org/2001/06/soap-encoding"
> enc:arrayType="xsd:int[9]">
> <item>1</item>
> <item>2</item>
> <item>3</item>
> </idsArray>
> </ns1:GetNamesByIds>
> </SOAP-ENV:Body>
>
> My AxisCPP service handles this just fine.
>
> BUT, my Java client generates XML that doesn't use the "<item>"
> construct, and it causes my CPP service to fail to parse the data.
> Here's the Java XML:
>
> <soapenv:Body>
> <ns1:GetNamesByIds
>
> soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
> xmlns:ns1="http://localhost/axis/csaapi">
> <objType xsi:type="xsd:int">0</objType>
> <ids soapenc:arrayType="xsd:int[9]"
> xsi:type="soapenc:Array"
> xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
> <ids xsi:type="xsd:int">1</ids>
> <ids xsi:type="xsd:int">2</ids>
> <ids xsi:type="xsd:int">3</ids>
> </ids>
> </ns1:GetNamesByIds>
> </soapenv:Body>
>
> Could someone give me advice on the best way to handle this? Note that
> I've already turned the MULTIREF option off to fix a different set of
> problems. I'd prefer to keep the RPC/Encoded style if at all possible.
>
> Thank you very much in advance!
>
> -Jonathan Beakley
> beakley@cisco.com