1 23 package fr.dyade.aaa.jndi2.soap; 24 25 import javax.naming.NamingException ; 26 27 import java.util.Hashtable ; 28 import java.lang.reflect.Method ; 29 30 36 public class SoapObjectHelper 37 { 38 43 public static Hashtable soapCode(Object obj) throws NamingException { 44 if (obj instanceof SoapObjectItf) { 45 Hashtable res = ((SoapObjectItf) obj).code(); 46 res.put("className", obj.getClass().getName()); 47 return res; 48 } else { 49 throw new NamingException ("Object " + obj.getClass().getName() 50 + " not codable into a SOAP Hashtable."); 51 } 52 } 53 54 59 public static Object soapDecode(Hashtable codedObject) throws NamingException 60 { 61 Object object = null; 62 63 try { 64 String className = (String ) codedObject.get("className"); 65 Class clazz = Class.forName(className); 66 object = clazz.newInstance(); 67 } catch (Throwable exc) { 68 throw new NamingException ("could not decode Hashtable [" + codedObject 69 + "] into an object: " + exc); 70 } 71 72 if (object instanceof SoapObjectItf) { 73 ((SoapObjectItf)object).decode(codedObject); 74 return object; 75 } else { 76 throw new NamingException ("hashtable [" + codedObject 77 + "] decoded into an unexpected object [" 78 + object + "]"); 79 } 80 } 81 } 82 | Popular Tags |