axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mmostt...@bco.com
Subject RE: Array of Objects in Axis and .NET interop
Date Mon, 27 Sep 2004 22:54:48 GMT
I tried this same approach but I then received an unknown element exception
with the Axis Java client.  In addition I didn't care for the defaulted
hardcoding of the "item" name which was causing problems in the .NET client
(especially in a situation where the modification of the generated .NET
client is not possible).

In addition I found that this change caused a service method that returns an
array to not return the correct xml results since it added extra wrapper and
used item.

NOTE: I have discovered also that by removing the field type description for
the array property from the helper class causes the serializer to output
correctly, with the wrapping element.  (although the Axis client is unable
to correctly deserialize).

marcus

-----Original Message-----
From: Eric Chijioke [mailto:echijioke@erisk.com] 
Sent: Monday, September 27, 2004 12:30 PM
To: axis-user@ws.apache.org
Cc: Tami Wright
Subject: RE: Array of Objects in Axis and .NET interop


Tami,

Here's what I've done to make it work with .NET:

I've located the following code in the
org.apache.axis.encoding.ser.ArraySerializer.serialize() method And in both
places, commented out the if(...) condition in order to place an array
wrapper around the elements for arrays specified using the <element
minOccurs="0" maxOccurs="unbounded"...> WSDL syntax.


 ------------ begin snippet (Line# 322) ------------------------
 
// if (!maxOccursUsage) {
//****** commented out *****//
      serializeAttr = null;  // since we are putting them here
      context.startElement(name, attributes);
     elementName = Constants.QNAME_LITERAL_ITEM; 
// }
//****** commented out *****//
 
 ------------ end snippet --------------------------------------
 

 With the corresponding serialization of a closing wrapper later on:
 

 ------------ begin snippet (Line# 363)--------------------------
 
// if (!maxOccursUsage)
//****** commented out *****//
            context.endElement();
 
 ------------ end snippet ---------------------------------------

 

In order to set the appropriate type of array elements, I also changed the
following code (a bit of a blind hack, but it works) in the same method
FROM:

 ------------ begin snippet (Line# 336)--------------------------

context.serialize(elementName, serializeAttr, aValue,
                                      componentQName, // prefered type QName
                                      true,   // Send null values
                                      null);  // Respect default type config

 ------------ end snippet ---------------------------------------

TO:

 ------------ begin snippet -------------------------------------

context.serialize(elementName, serializeAttr, aValue,
	
msgContext.getTypeMapping().getXMLType(aValue.getClass(),null,encoded),
// prefered type QName
	true,   // Send null values
	 null);  // Respect default type config

 ------------ end snippet ---------------------------------------


Remember, your .NET client needs to use the 
System.Xml.Serialization.XmlArrayItemAttribute("item")]
attribute on your web service methods (in your Reference.cs file) in order
to consume arrays serialized form axis with elements named <item>.

I hope this helps,
Eric








-----Original Message-----
From: Tami Wright [mailto:ttwright@myfamilyinc.com] 
Sent: Monday, September 27, 2004 12:25 PM
To: axis-user@ws.apache.org
Subject: Array of Objects in Axis and .NET interop

Hi,

I wondered what the status was with the message thread originally posted by
Eric Chijioke entitled "Axis and .NET interoperability - Arrays". Any
interim solution that can be posted until the bug is resolved would be
appreciated.

Best Regards,

tami

Mime
View raw message