Hi, I am having a hard time using Axis with xml schema generated datatypes. Here is my problem:
I start with an xml schema that contains some custom datatypes: <complexType name="Sequence"> <sequence> <element name="id" type="string" /> <element name="description" type="string" /> <element name="data" type="string" /> <element name="type" type="tns:SequenceType" /> </sequence> </complexType> <simpleType name="SequenceType"> <restriction base="string"> <enumeration value="dna" /> <enumeration value="rna" /> <enumeration value="protein" /> <enumeration value="nucleotide" /> <enumeration value="unknown" /> </restriction> </simpleType> <complexType name="ListOfSequence"> <sequence> <element name="sequence" type="tns:Sequence" minOccurs="0" maxOccurs="unbounded"/> </sequence> </complexType> I then use xjc (from JAXB) to generate the java classes which then are used to build webservices. When deploy the webservice, I specify the typemapping as follows: <beanMapping qname="myNS:ListOfSequence" xmlns:myNS="http://cs.nmsu.edu/bsis/schema/datatype" languageSpecificType="java:edu.nmsu.cs.bsis.schema.datatype.ListOfSequence"/> <beanMapping qname="myNS:Sequence" xmlns:myNS="http://cs.nmsu.edu/bsis/schema/datatype" languageSpecificType="java:edu.nmsu.cs.bsis.schema.datatype.Sequence"/> <typeMapping xmlns:myNS="http://cs.nmsu.edu/bsis/schema/datatype" qname="myNS:SequenceType" languageSpecificType ="java:edu.nmsu.cs.bsis.schema.datatype.SequenceType" serializer="org.apache.axis.encoding.ser.EnumSerializerFactory" deserializer ="org.apache.axis.encoding.ser.EnumDeserializerFactory" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" /> I then wrote client to visit this service. There are several problems when doing so: 1. the Enum type SequenceType is not deserialized correctly (it generates null pointer error). After explore the source code of EnumDeserializer, I found that it is using a fromString() method to deserialize the Enum type. This method is not generated with xjc. That is, the Enum Ser/Deser will not work with xjc generated Enum type. 2. xjc convert the ListOfSequence type to a java class that contains a List<Sequence> data member. It is serialized as an array but is not deserialized correctly (I always get zero on the list size). Because of those problems, I noticed that Axis (I am using the 1.3 version) is not comforming to the JAXB framework. So I start to use the WSDL2Java tool to generate the datatypes from the xml schema. But still I got other problems: 1. the wsdl2java will not even generate the ListOfSequence class unless I add another subelement to the schema definition, like so, <complexType name="ListOfSequence"> <sequence> <element name="sequence" type="tns:Sequence" minOccurs="0" maxOccurs="unbounded"/> <element name="size" type="xsd:integer"/> </sequence> </complexType> which I don't like to do so (any solutions?) 2. the wsdl2java tool generates the ListOfSequence class with a Sequence Array data member (Sequence[]). I then redeployed the webservice (with the same typemapping as above) and wrote a client to visit it. However, it always give me a ClassCastException as follows: AxisFault faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException faultSubcode: faultString: java.lang.ClassCastException: org.apache.axis.encoding.ser.BeanDeserializer faultActor: faultNode: faultDetail: {http://xml.apache.org/axis/}hostname:bio2 java.lang.ClassCastException: org.apache.axis.encoding.ser.BeanDeserializer at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222) at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129) at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087) at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source) at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) at javax.xml.parsers.SAXParser.parse(SAXParser.java:375) at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227) at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696) at org.apache.axis.Message.getSOAPEnvelope(Message.java:435) at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62) at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206) at org.apache.axis.client.Call.invokeEngine(Call.java:2784) at org.apache.axis.client.Call.invoke(Call.java:2767) at org.apache.axis.client.Call.invoke(Call.java:2443) at org.apache.axis.client.Call.invoke(Call.java:2366) at org.apache.axis.client.Call.invoke(Call.java:1812) I think the error is caused when it is trying to deserialize the Sequence[] object contained in the ListOfSequence object. I am wondering should I tell axis about the type mapping of an array that contains user defined datatypes. if so, how to do it? I searched the forum for this subject but could find very useful information. Your help is highly appreciated. Plus, I'd really like to use xjc generated classes since it looks much better than the wsdl2java tool generated classes. But that means I have to rewrite many of the ser/deser that is built into axis. The example axis gave under samples/encoding is too naive and requires all data fields be public. I looked at the source code for the build in ser/deserizers in axis but the documentation is poor (the custom ser/deser is also missing from the userguide). I am wondering can anyone provide any suggestions on how to write ser/deser for java List like datatypes? Does other webservice container like glassfish better at this regard? thanks again frank -- View this message in context: http://www.nabble.com/Serialization-of-Array-of-Custom-datatypes-tf3323781.html#a9240226 Sent from the Axis - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]