HI:
I just write a program following the sample - encoding, but it dosen't
work.
-----------------------------------------------------------------------
class TaskBroker{
static class Task{
public Integer taskType;
public String taskName;
public Integer taskCost;
static final int CO = 0;
static final int NC = 1;
public int GetCost(){
return taskCost.intValue();
}
public boolean IsCooperativeWork(){
return (taskType.intValue() == CO);
}
public boolean IsNotCooperativeWork(){
return (taskType.intValue() == NC);
}
}
static class Person{
public String personName;
public Integer personMoney;
public String toString()
{
return getStringVal("", this);
}
public String getStringVal(String indent, Person topLevel)
{
String ret = "\n" + indent + "Person:\n";
ret += indent + " Name [" + personName + "]\n";
ret += indent + " Money ["+ personMoney+"]\n";
return ret;
}
}
public Task taskMember = new Task();
public Person personMember= new Person();
}
-------------------------------------------------------------------------
I also write the serialization&deserialization for the class Task and
Person. when I test Task and Person, they work well.
But when I test the TaskBroker, get something wrong:
------------------------------------------------------
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:myParam xsi:type="xsd:string">this is a string</ns1:myParam>
<struct href="#id0"/>
</ns1:method1>
<multiRef id="id0" soapenc:root="0"
soapenv:encodingStyle="http://schemas.xmls
oap.org/soap/encoding/" xsi:type="ns2:TaskBroker"
xmlns:soapenc="http://schemas.
xmlsoap.org/soap/encoding/" xmlns:ns2="typeNS">
<taskMember href="#id1"/>
<personMember href="#id2"/>
</multiRef>
<multiRef id="id2" soapenc:root="0"
soapenv:encodingStyle="http://schemas.xmls
oap.org/soap/encoding/" xsi:type="xsd:anyType"
xmlns:soapenc="http://schemas.xml
soap.org/soap/encoding/">
Person:
Name [null]
Money [null]
</multiRef>
<multiRef id="id1" soapenc:root="0"
soapenv:encodingStyle="http://schemas.xmls
oap.org/soap/encoding/" xsi:type="xsd:anyType"
xmlns:soapenc="http://schemas.xml
soap.org/soap/encoding/">TaskBroker$Task@39b538</multiRef>
</soapenv:Body>
</soapenv:Envelope>
Testing deserialization...
java.lang.NullPointerException
at TaskBrokerDeser.onStartChild(TaskBrokerDeser.java:72)
at
org.apache.axis.encoding.DeserializationContextImpl.startElement(Dese
rializationContextImpl.java:883)
at
org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.ja
va:158)
at
org.apache.axis.message.MessageElement.publishToHandler(MessageElemen
t.java:681)
at
org.apache.axis.encoding.DeserializerImpl.startElement(DeserializerIm
pl.java:369)
at
org.apache.axis.encoding.DeserializationContextImpl.startElement(Dese
rializationContextImpl.java:896)
at
org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.ja
va:158)
at
org.apache.axis.message.MessageElement.publishToHandler(MessageElemen
t.java:681)
at
org.apache.axis.message.RPCElement.deserialize(RPCElement.java:244)
at org.apache.axis.message.RPCElement.getParam(RPCElement.java:253)
at TestTaskBroker.main(TestTaskBroker.java:86)
-------------------------------------------------------------------------
So any one can give me an example of how to write the inner class
deserialization?
Thanks!!
:)
_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com