You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by Peter Molettiere <pi...@axonstudios.net> on 2004/12/10 19:06:17 UTC
Problems with MapSerializer
It looks like there's a bug with the MapSerializer. If I try to
serialize this map:
HashMap map = new HashMap();
map.put("self", map);
It produces the following xml (which seems correct to me):
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<ns1:method1 xmlns:ns1="urn:GreenArray">
<struct href="#id0"/>
</ns1:method1>
<multiRef id="id0" soapenc:root="0"
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xsi:type="ns2:Map"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns2="http://xml.apache.org/xml-soap">
<item>
<key xsi:type="soapenc:string">self</key>
<value href="#id0"/>
</item>
</multiRef>
</soapenv:Body>
</soapenv:Envelope>
(I'm creating my message like this, thus the struct and method1
elements:)
AxisServer server = new AxisServer();
server.setOption(AxisEngine.PROP_DOMULTIREFS, Boolean.TRUE);
MessageContext msgContext = new MessageContext(server);
msgContext.setProperty(AxisEngine.PROP_DOMULTIREFS,
Boolean.TRUE);
SOAPEnvelope msg = new SOAPEnvelope();
RPCParam arg = new RPCParam("", "struct", data);
RPCElement body = new RPCElement(SOAPFactory.NAMESPACE,
"method1",
new Object[]{arg});
msg.addBodyElement(body);
StringWriter writer = new StringWriter();
SerializationContext context = new SerializationContext(writer,
msgContext);
TypeMappingRegistry reg = context.getTypeMappingRegistry();
lastRegistry = reg;
msg.output(context);
String messageStr = writer.toString();
System.err.println(messageStr);
Reader reader = new StringReader(messageStr);
DeserializationContext dser = new DeserializationContext
(new InputSource(reader), msgContext,
org.apache.axis.Message.REQUEST);
dser.parse();
SOAPEnvelope env = dser.getEnvelope();
RPCElement rpcElem = (RPCElement) env.getFirstBody();
RPCParam struct = rpcElem.getParam(WRAP_ELEMENT);
This last struct is always NULL however, if the map I use contains any
type of circular reference. Note that if there is no circular
reference, everything deserializes correctly.
Any and all help with this is greatly appreciated.
--
Peter Molettiere
Senior Engineer
Truereq, Inc.
http://www.truereq.com/