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 Eric Chijioke <ec...@erisk.com> on 2004/09/09 18:03:18 UTC

Axis and .NET interoperability - Arrays

I have read a LOT of discussions concerning problems serializing and
deserializing arrays between an Axis server and a .NET client but can't
seem to find any definitive discussion/document. Is there one?

Secondly,

I have a .NET client that is attempting to deserialize an array of
custom types that are serialized by an Axis server.
I am using Axis 1.2 beta.
The Axis server is configured for document/litteral (wrapped).
The method being invoked by the client is called getFactors();



The SOAP response being sent by the server looks as follows:

--------------------------- getFactors Reponse
-------------------------------

<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope ...namespaces omitted...>
 <soapenv:Body>
  <getFactorsResponse xmlns="http://object.hydra.com">
   <factors xsi:type="ns1:Factor" xmlns:ns1="http://object.hydra.com">
    <name>Root Factor</name>
    <id>f_root</id>
   </factors>
   <factors xsi:type="ns2:Factor" xmlns:ns2="http://object.hydra.com">
    <name>Factor 1</name>
    <id>f_1</id>
   </factors>
   <factors xsi:type="ns3:Factor" xmlns:ns3="http://object.hydra.com">
    <name>Factor 2</name>
    <id>f_2</id>
   </factors>
  </getFactorsResponse>
 </soapenv:Body>
</soapenv:Envelope>

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



The relevant fragments from my wsdd file are as follows (some namespaces
omitted):

----------------- WSDD operation and typemapping fragments
-------------------

<operation name="getFactors" qname="ns:getFactors"
returnQName="ns1:factors" returnType="ns1:FactorArray">
	<parameter name="ids" type="ns1:stringArray"/>
</operation>

<typeMapping qname="ns1:FactorArray"
type="java:com.erisk.hydra.object.Factor[]"
serializer="org.apache.axis.encoding.ser.ArraySerializerFactory"
deserializer="org.apache.axis.encoding.ser.ArrayDeserializerFactory"
encodingStyle=""/>

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



The relevant fragments from my WSDL are as follows (some namespaces
omitted):

--------- WSDL element and type fragments (operation & message ommitted)
-------

<element name="getFactors">
	<complexType>
		<sequence>
			<element minOccurs="1" maxOccurs="1" name="ids"
type="intf:stringArray"/>
		</sequence>
	</complexType>
</element>

<element name="getFactorsResponse">
	<complexType>
		<sequence>
			<element minOccurs="1" maxOccurs="1"
name="factors" type="intf:FactorArray"/>
		</sequence>
	</complexType>
</element>

<complexType name="FactorArray">
	<sequence>
		<element name="factor" type="intf:Factor" minOccurs="0"
maxOccurs="unbounded"/>
	</sequence>
</complexType>

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


I have a couple of questions:

1) How come Axis doesn't create a single <factors> container element
with many <factor> elements as the WSDL schema seems to describe? The
<factors> array item elements in the response  are being driven by the
{returnQName="ns1:factors"} in the wsdd operation. Why isn't it using
the FactorArray definition from the WSDL?

2) If this response is correct (with no <factors> container element),
how does one make this work with a .NET client which seems to expect a
container element (to provide to the XmlArrayAttribute if your familiar
with .NET webservices)?


Thanks

Eric Chijioke 
echijioke@erisk.com