Esempio n. 1
0
  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();
  }