hi:
I changed the sample code of Encoding, and added another class(DataNew) to
the class(Data).
It works fine - can serialize and deserialize correctly.
Class A{
Class B;
}
But after I changed the class(DataNew) to DataNew(array),
Class A{
Class B[];
}
the deserialize dosen't work correctly, every time I got the same mistake:
-------------------------------------------------------------------------------------- \
-------------------------------
E:\axis>java samples.encoding.TestSer
Serialized msg:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmln
s:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSc
hema-instance">
<soapenv:Body>
<ns1:method1 xmlns:ns1="urn:myNamespace">
<ns1:testParam xsi:type="xsd:string">this is a string</ns1:testParam>
<struct href=""/>
</ns1:method1>
<multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmls
oap.org/soap/encoding/" xsi:type="ns2:Data" xmlns:soapenc="http://schemas.xmlsoa
p.org/soap/encoding/" xmlns:ns2="typeNS">
<stringMember xsi:type="xsd:string">String member</stringMember>
<floatMember xsi:type="xsd:float">1.23</floatMember>
<dataMember xsi:type="soapenc:Array" soapenc:arrayType="ns2:DataNew[2]">
<item href=""/>
<item href=""/>
</dataMember>
</multiRef>
<multiRef id="id2" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmls
oap.org/soap/encoding/" xsi:type="ns3:DataNew" xmlns:ns3="typeNS" xmlns:soapenc=
"http://schemas.xmlsoap.org/soap/encoding/">
<stringMember xsi:type="xsd:string">tttt</stringMember>
<floatMember xsi:type="xsd:float">66.66</floatMember>
</multiRef>
<multiRef id="id1" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmls
oap.org/soap/encoding/" xsi:type="ns4:DataNew" xmlns:ns4="typeNS" xmlns:soapenc=
"http://schemas.xmlsoap.org/soap/encoding/">
<stringMember xsi:type="xsd:string">another str member</stringMember>
<floatMember xsi:type="xsd:float">99.999</floatMember>
</multiRef>
</soapenv:Body>
</soapenv:Envelope>
-------
Testing deserialization...
local name item
org.xml.sax.SAXException: Invalid element in DataNew struct - item
at samples.encoding.DataNewDeser.onStartChild(DataNewDeser.java:44)
at org.apache.axis.encoding.DeserializationContextImpl.startElement(Dese
rializationContextImpl.java:912)
at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.ja
va:200)
at org.apache.axis.message.MessageElement.publishToHandler(MessageElemen
t.java:693)
at org.apache.axis.encoding.DeserializerImpl.startElement(DeserializerIm
pl.java:404)
at org.apache.axis.encoding.DeserializationContextImpl.startElement(Dese
rializationContextImpl.java:925)
at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.ja
va:200)
at org.apache.axis.message.MessageElement.publishToHandler(MessageElemen
t.java:693)
at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:299)
at org.apache.axis.message.RPCElement.getParam(RPCElement.java:308)
at samples.encoding.TestSer.main(TestSer.java:114)
------------------------------------------------------------------------------------- \
-------------------------------
It seems that the derialization class of DataNew, always look - "item" in the struct
of DataNew,. But these is no definition of item in the class, so program will always
fails here.
So any one can give some ideas about how to handle the array deserialize in custom \
datatype?
or show me some sample codes.
BTW, I just copied the dataser.java file to datanewser.java and changed the
"data" to "datanew". I need other changes?
thanks in advance!
David
Post your free ad now! Yahoo! Canada Personals