public Object deserialize(InputStream is, Hashtable extendedContext) throws Exception { // getting deserializer Class targetCls = (Class) extendedContext.get("targetClass"); Object objectOfTargetCls = targetCls.newInstance(); TypeDesc desc = (TypeDesc) objectOfTargetCls .getClass() .getMethod("getTypeDesc", new Class[] {}) .invoke(objectOfTargetCls, new Object[] {}); final QName xmlType; // = desc.getXmlType(); xmlType = new QName( "http://" + objectOfTargetCls.getClass().getName(), org.uengine.util.UEngineUtil.getClassNameOnly(objectOfTargetCls.getClass())); Deserializer dser = (Deserializer) objectOfTargetCls .getClass() .getMethod("getDeserializer", new Class[] {String.class, Class.class, QName.class}) .invoke( objectOfTargetCls, new Object[] {"", objectOfTargetCls.getClass(), xmlType}); // end System.out.println("dser:" + dser); DeserializationContext context = new DeserializationContextImpl( new org.xml.sax.InputSource(is), /* new MessageContext(null){ public String getEncodingStyle(){ return xmlType.getNamespaceURI(); } },*/ new MessageContext(new AxisClient()), // Message.RESPONSE "PurchaseOrder"); boolean oldVal = context.isDoneParsing(); ((DeserializationContextImpl) context).deserializing(true); context.pushElementHandler(new EnvelopeHandler((SOAPHandler) dser)); // context.getRecorder().replay(0, -1, (org.xml.sax.ContentHandler)context); context.getRecorder().replay(0, -1, (org.xml.sax.ContentHandler) context); ((DeserializationContextImpl) context).deserializing(oldVal); context.parse(); return dser.getValue(); }
public SOAPHandler onStartChild( String namespace, String localName, String prefix, Attributes attributes, DeserializationContext context) throws SAXException { QName typeQName = context.getTypeFromAttributes(namespace, localName, attributes); Deserializer dser = context.getDeserializerForType(typeQName); // If no deserializer, use the base DeserializerImpl. if (dser == null) dser = new DeserializerImpl(); // When the child value is ready, we // want our set method to be invoked. // To do this register a DeserializeTarget on the // new Deserializer. DeserializerTarget dt = null; if (context.isNil(attributes)) { dt = new DeserializerTarget(this, NILHINT); } else if (localName.equals("key")) { dt = new DeserializerTarget(this, KEYHINT); } else if (localName.equals("value")) { dt = new DeserializerTarget(this, VALHINT); } else { // Do nothing } if (dt != null) { dser.registerValueTarget(dt); } // We need this guy to complete for us to complete. addChildDeserializer(dser); return (SOAPHandler) dser; }