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 Mitch Gitman <mg...@usa.net> on 2003/01/07 17:05:05 UTC

.NET client and nested arrays

I'm trying to get an Axis server and a C#/.NET client working together. I'm 
encountering one interop showstopper that appears to be more .NET's fault 
than Axis'.

Whenever the bean-serialized object I send as a response has for a member 
an array of instances of either strings or some other beany object, the C# 
client complains that it can't deserialize the response. Now, I have only 
tried this on the C# client when the nested array is empty; I haven't tried 
non-empty.

Background:
* I've tested Axis client-to-Axis server, and it works.
* I am using -- and would like to continue to use -- RPC style/SOAP 
encoding rather than document style/literal encoding, unless/until RPC 
proves unreasonable.
* I run .NET's wsdl.exe console application to generate a proxy client 
source file, SoldierComponentService.cs, based on the Axis-generated WSDL. 
This works fine. The class compiles fine. The C# test classes that I write 
based on that proxy also compile fine.

Here is the .NET client's error message:
There is an error in XML document (14, 14).
    at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader)
    at 
System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage 
message, WebResponse response, Stream responseStream)
    at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String 
methodName, Object[] parameters)
    at Foo.Bar.SoldierComponentService.addOfficer(String in0)
    at Test.Foo.Bar.SoldierComponentTest.Main()

For an object that has a single nested array, the location of the error 
traces to the end of the line after the line containing the nested array. 
Here's the line/element with the nested array:
    <soldersAsArray xsi:type="soapenc:Array" 
soapenc:arrayType="ns2:Soldier[0]"/>

For an object that has two nested arrays, the location of the error traces 
to the end of the line after the SECOND line containing the nested array. 
Here are the two lines/elements with nested arrays:
    <officersAsArray xsi:type="soapenc:Array" 
soapenc:arrayType="xsd:string[0]"/>
    <noncomissionedsAsArray xsi:type="soapenc:Array" 
soapenc:arrayType="xsd:string[0]"/>

The associated Java classes have public methods, getSuchAndSuchAsArray(), 
that return a raw array of the appropriate type. The type (if it's a custom 
type) gets correctly translated to source code by .NET's wsdl.exe. 
Whadayaknow, when I comment out those get-array methods, the .NET client 
deserializes the objects correctly.

The definition of soapenc is found in the response's multiRef element:
   <multiRef id="id0" soapenc:root="0" 
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 
xsi:type="ns2:OfficerBranch" 
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
xmlns:ns2="urn:bar.foo">

So how do I get the "soapenc:Array" and soapenc:arrayType to work on the 
.NET client?
=============================================
Here's the full response with the object that has two nested arrays:
HTTP/1.1 100 Continue  HTTP/1.1 200 OK Content-Type: text/xml; 
charset=utf-8 Transfer-Encoding: chunked Date: Mon, 06 Jan 2003 21:31:37 
GMT Server: Apache Coyote/1.0  411
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <soapenv:Body>
   <ns1:addOfficerResponse 
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 
xmlns:ns1="urn:bar.foo">
    <addOfficerReturn href="#id0"/>
   </ns1:addOfficerResponse>
   <multiRef id="id0" soapenc:root="0" 
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 
xsi:type="ns2:OfficerBranch" 
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
xmlns:ns2="urn:bar.foo">
    <baseTag xsi:type="xsd:string">officer</baseTag>
    <officersAsArray xsi:type="soapenc:Array" 
soapenc:arrayType="xsd:string[0]"/>
    <key xsi:type="xsd:string">0000000007</key>
    <name xsi:type="xsd:string">home</name>
    <parent xsi:type="xsd:string">root</parent>
    <noncomissionedsAsArray xsi:type="soapenc:Array" 
soapenc:arrayType="xsd:string[0]"/>
   </multiRef>
  </soapenv:Body>
</soapenv:Envelope> 0