1 2 package test.rpc; 3 4 import org.apache.axis.client.Call; 5 import org.apache.axis.client.Service; 6 import org.apache.axis.encoding.ser.BeanDeserializerFactory; 7 import org.apache.axis.encoding.ser.BeanSerializerFactory; 8 import org.apache.axis.Constants; 9 10 import javax.xml.namespace.QName ; 11 import javax.xml.rpc.ParameterMode ; 12 import java.util.Calendar ; 13 14 public final class IF3SOAPProxy implements IF3SOAP 15 { 16 private String m_service; 17 private String m_url; 18 private QName m_beanQName; 19 private QName m_arrayQName; 20 21 public IF3SOAPProxy(String service, String url) 22 { 23 m_service = service; 24 m_url = url; 25 m_beanQName = new QName ("urn:" + m_service, "Bean"); 26 m_arrayQName = Constants.SOAP_ARRAY; 27 } 28 29 public IF1 getBeanById(String id) 30 throws Exception 31 { 32 IF1 bean = null; 33 34 if (id == null) 35 throw new Exception ("invalid id"); 36 37 Call call = getCall(); 38 call.setTargetEndpointAddress(m_url); 39 call.setOperationName(new QName (m_service, "getBeanById")); 40 call.addParameter("id", org.apache.axis.Constants.XSD_STRING, ParameterMode.IN); 41 call.setReturnType(m_beanQName); 42 bean = (IF1) call.invoke(new Object [] { id }); 43 44 return bean; 45 } 46 47 public IF1[] getAllBeans() 48 throws Exception 49 { 50 return getAllBeans(null); 51 } 52 53 public IF1[] getAllBeans(String [] filter) 54 throws Exception 55 { 56 IF1[] beans = null; 57 58 Call call = getCall(); 59 call.setTargetEndpointAddress(m_url); 60 call.setOperationName(new QName (m_service, "getAllBeans")); 61 call.setReturnType(m_arrayQName); 62 if (filter == null) 63 beans = (IF1[]) call.invoke(new Object [0]); 64 else 65 { 66 call.addParameter("filter", m_arrayQName, ParameterMode.IN); 67 beans = (IF1[]) call.invoke(new Object [] { filter }); 68 } 69 70 return beans; 71 } 72 73 public String [] getAllCategories() 74 throws Exception 75 { 76 String [] categories = null; 77 78 Call call = getCall(); 79 call.setTargetEndpointAddress(m_url); 80 call.setOperationName(new QName (m_service, "getAllCategories")); 81 call.setReturnType(m_arrayQName); 82 categories = (String []) call.invoke(new Object [0]); 83 84 return categories; 85 } 86 87 public IF1[] getBeansByCategory(String category) 88 throws Exception 89 { 90 return getBeansByCategory(category, (String []) null); 91 } 92 93 public IF1[] getBeansByCategory(String category, String [] filter) 94 throws Exception 95 { 96 IF1[] beans = null; 97 98 if (category == null) 99 throw new Exception ("invalid category"); 100 101 Call call = getCall(); 102 call.setTargetEndpointAddress(m_url); 103 call.setOperationName(new QName (m_service, "getBeansByCategory")); 104 call.setReturnType(m_arrayQName); 105 call.addParameter("category", org.apache.axis.Constants.XSD_STRING, ParameterMode.IN); 106 if (filter == null) 107 beans = (IF1[]) call.invoke(new Object [] { category }); 108 else 109 { 110 call.addParameter("filter", m_arrayQName, ParameterMode.IN); 111 beans = (IF1[]) call.invoke(new Object [] { category, filter }); 112 } 113 114 return beans; 115 } 116 117 public IF1[] getBeansByDate(Calendar [] dates) 118 throws Exception 119 { 120 return getBeansByDate(dates, null); 121 } 122 123 public IF1[] getBeansByDate(Calendar [] dates, String [] filter) 124 throws Exception 125 { 126 IF1[] beans = null; 127 128 if (dates == null) 129 throw new Exception ("invalid dates"); 130 131 Call call = getCall(); 132 call.setTargetEndpointAddress(m_url); 133 call.setOperationName(new QName (m_service, "getBeansByDate")); 134 call.setReturnType(m_arrayQName); 135 call.addParameter("dates", m_arrayQName, ParameterMode.IN); 136 if (filter == null) 137 beans = (IF1[]) call.invoke(new Object [] { dates }); 138 else 139 { 140 call.addParameter("filter", m_arrayQName, ParameterMode.IN); 141 beans = (IF1[]) call.invoke(new Object [] { dates, filter }); 142 } 143 144 return beans; 145 } 146 147 public IF1[] getBeansByExpression(int expType, String expression) 148 throws Exception 149 { 150 return getBeansByExpression(expType, expression, null); 151 } 152 153 public IF1[] getBeansByExpression(int expType, String expression, String [] filter) 154 throws Exception 155 { 156 IF1[] beans = null; 157 158 if (expression == null) 159 throw new Exception ("invalid expression"); 160 161 Call call = getCall(); 162 call.setTargetEndpointAddress(m_url); 163 call.setOperationName(new QName (m_service, "getBeansByExpression")); 164 call.setReturnType(m_arrayQName); 165 call.addParameter("expType", org.apache.axis.Constants.XSD_INT, ParameterMode.IN); 166 call.addParameter("expression", org.apache.axis.Constants.XSD_STRING, ParameterMode.IN); 167 if (filter == null) 168 beans = (IF1[]) call.invoke(new Object [] { new Integer (expType), expression }); 169 else 170 { 171 call.addParameter("filter", m_arrayQName, ParameterMode.IN); 172 beans = (IF1[]) call.invoke(new Object [] { new Integer (expType), expression, filter }); 173 } 174 175 return beans; 176 } 177 178 public String getXMLForBean(IF1 bean) 179 throws Exception 180 { 181 String xml = null; 182 183 if (bean == null) 184 throw new Exception ("invalid bean"); 185 186 Call call = getCall(); 187 call.setTargetEndpointAddress(m_url); 188 call.setOperationName(new QName (m_service, "getXMLForBean")); 189 call.addParameter("bean", m_beanQName, ParameterMode.IN); 190 call.setReturnType(org.apache.axis.Constants.XSD_STRING); 191 xml = (String ) call.invoke(new Object [] { bean }); 192 193 return xml; 194 } 195 196 public IF1[] getBeansByCategory(String ifId, String category) 197 throws Exception 198 { 199 return getBeansByCategory(ifId, category, null); 200 } 201 202 public IF1[] getBeansByCategory(String ifId, String category, String [] filter) 203 throws Exception 204 { 205 IF1[] beans = null; 206 207 if (ifId == null) 208 throw new Exception ("invalid ifId"); 209 if (category == null) 210 throw new Exception ("invalid category"); 211 212 Call call = getCall(); 213 call.setTargetEndpointAddress(m_url); 214 call.setOperationName(new QName (m_service, "getBeansByCategory")); 215 call.setReturnType(m_arrayQName); 216 call.addParameter("ifId", org.apache.axis.Constants.XSD_STRING, ParameterMode.IN); 217 call.addParameter("category", org.apache.axis.Constants.XSD_STRING, ParameterMode.IN); 218 if (filter == null) 219 beans = (IF1[]) call.invoke(new Object [] { ifId, category }); 220 else 221 { 222 call.addParameter("filter", m_arrayQName, ParameterMode.IN); 223 beans = (IF1[]) call.invoke(new Object [] { ifId, category, filter }); 224 } 225 226 return beans; 227 } 228 229 public IF1[] getBeansByDate(String ifId, Calendar [] dates) 230 throws Exception 231 { 232 return getBeansByDate(ifId, dates, null); 233 } 234 235 public IF1[] getBeansByDate(String ifId, Calendar [] dates, String [] filter) 236 throws Exception 237 { 238 IF1[] beans = null; 239 240 if (ifId == null) 241 throw new Exception ("invalid ifId"); 242 if (dates == null) 243 throw new Exception ("invalid dates"); 244 245 Call call = getCall(); 246 call.setTargetEndpointAddress(m_url); 247 call.setOperationName(new QName (m_service, "getBeansByDate")); 248 call.setReturnType(m_arrayQName); 249 call.addParameter("ifId", org.apache.axis.Constants.XSD_STRING, ParameterMode.IN); 250 call.addParameter("dates", m_arrayQName, ParameterMode.IN); 251 if (filter == null) 252 beans = (IF1[]) call.invoke(new Object [] { ifId, dates }); 253 else 254 { 255 call.addParameter("filter", m_arrayQName, ParameterMode.IN); 256 beans = (IF1[]) call.invoke(new Object [] { ifId, dates, filter }); 257 } 258 259 return beans; 260 } 261 262 public IF1[] getBeansByExpression(String ifId, int expType, String expression) 263 throws Exception 264 { 265 return getBeansByExpression(ifId, expType, expression, null); 266 } 267 268 public IF1[] getBeansByExpression(String ifId, int expType, String expression, String [] filter) 269 throws Exception 270 { 271 IF1[] beans = null; 272 273 if (ifId == null) 274 throw new Exception ("invalid ifId"); 275 if (expression == null) 276 throw new Exception ("invalid expression"); 277 278 Call call = getCall(); 279 call.setTargetEndpointAddress(m_url); 280 call.setOperationName(new QName (m_service, "getBeansByExpression")); 281 call.setReturnType(m_arrayQName); 282 call.addParameter("ifId", org.apache.axis.Constants.XSD_STRING, ParameterMode.IN); 283 call.addParameter("expType", org.apache.axis.Constants.XSD_INT, ParameterMode.IN); 284 call.addParameter("expression", org.apache.axis.Constants.XSD_STRING, ParameterMode.IN); 285 if (filter == null) 286 beans = (IF1[]) call.invoke(new Object [] { ifId, new Integer (expType), expression }); 287 else 288 { 289 call.addParameter("filter", m_arrayQName, ParameterMode.IN); 290 beans = (IF1[]) call.invoke(new Object [] { ifId, new Integer (expType), expression, filter }); 291 } 292 293 return beans; 294 } 295 296 private Call getCall() 297 throws Exception 298 { 299 Call call = null; 300 Service service = new Service(); 301 call = (Call) service.createCall(); 302 303 call.registerTypeMapping(Bean.class, m_beanQName, 304 new BeanSerializerFactory(Bean.class, m_beanQName), 305 new BeanDeserializerFactory(Bean.class, m_beanQName)); 306 return call; 307 } 308 } 309 310 | Popular Tags |