1 23 package com.scalagent.kjndi.ksoap; 24 25 import java.lang.*; 26 import java.util.Vector ; 27 import java.util.Hashtable ; 28 29 import com.scalagent.ksoap.SoapObject; 30 31 public class ConversionSoapHelper { 32 33 public static final String NAMESPACE = "urn:JndiService"; 34 35 public static SoapObject getSoapObject(String action, String name, Object object) { 36 37 SoapObject sO = null; 38 39 if (action.equals("bind")) { 40 sO = getSoapBind(action,name,object); 41 } else if (action.equals("lookup")) { 42 sO = getSoapLookup(action,name,object); 43 } else if (action.equals("rebind")) { 44 sO = getSoapRebind(action,name,object); 45 } else if (action.equals("unbind")) { 46 sO = getSoapUnbind(action,name,object); 47 } 48 return sO; 49 } 50 51 private static SoapObject getSoapBind(String action, String name, Object obj) { 52 SoapObject sO = new SoapObject(NAMESPACE, action); 53 return sO; 56 } 57 58 private static SoapObject getSoapLookup(String action, String name, Object obj) { 59 SoapObject sO = new SoapObject(NAMESPACE, action); 60 sO.addProperty("name",name); 61 return sO; 62 } 63 64 private static SoapObject getSoapRebind(String action, String name, Object obj) { 65 SoapObject sO = new SoapObject(NAMESPACE, action); 66 return sO; 69 } 70 71 private static SoapObject getSoapUnbind(String action, String name, Object obj) { 72 SoapObject sO = new SoapObject(NAMESPACE, action); 73 sO.addProperty("name",name); 74 return sO; 75 } 76 77 78 81 public static Object getObject(SoapObject sO) 82 throws Exception { 83 84 Hashtable h = null; 85 String nameSpace = sO.getNamespace(); 86 String name = sO.getName(); 87 88 if (nameSpace.equals(NAMESPACE)) { 89 if (name.equals("lookupResponse") || 90 name.equals("bindResponse") || 91 name.equals("unbindResponse") || 92 name.equals("rebindResponse")) { 93 Object o = sO.getProperty("return"); 94 h = (Hashtable ) sO.getProperty("return"); 95 } else if (name.equals("sendResponse")) { 96 return null; 97 } else { 98 throw new Exception ("SoapObject " + name 99 + " can't be converted to a Hashtable."); 100 } 101 } else { 102 throw new Exception ("SoapObject " + nameSpace 103 + " != urn:JndiService."); 104 } 105 106 String className = (String ) h.get("className"); 107 if (className == null) 108 throw new Exception ("SoapObject " + name 109 + " no className found."); 110 111 if (className.equals("org.objectweb.joram.client.jms.soap.SoapConnectionFactory")) { 112 return com.scalagent.kjoram.ksoap.SoapConnectionFactory.decode(h); 113 } else if (className.equals("org.objectweb.joram.client.jms.Queue")){ 114 return com.scalagent.kjoram.Queue.decode(h); 115 } else if (className.equals("org.objectweb.joram.client.jms.Topic")){ 116 return com.scalagent.kjoram.Topic.decode(h); 117 } else if (className.equals("org.objectweb.joram.client.jms.TemporaryQueue")){ 118 return com.scalagent.kjoram.TemporaryQueue.decode(h); 119 } else if (className.equals("org.objectweb.joram.client.jms.TemporaryTopic")){ 120 return com.scalagent.kjoram.TemporaryTopic.decode(h); 121 } 122 throw new Exception ("SoapObject " + className 123 + " can't be converted to an Object."); 124 } 125 } 126 | Popular Tags |