1 19 package org.openharmonise.him.harmonise; 20 21 import java.net.*; 22 import java.net.URL ; 23 import java.rmi.RemoteException ; 24 import java.util.*; 25 26 import javax.xml.namespace.QName ; 27 import javax.xml.rpc.ServiceException ; 28 29 import org.apache.axis.client.*; 30 import org.apache.axis.encoding.ser.*; 31 32 40 public class ConfigSettingsClient { 41 42 45 public static final String OPENHARMONISE_WEBSERVICE_NAMESPACE_URI = "http://www.openharmonise.org/"; 46 47 50 public ConfigSettingsClient() { 51 super(); 52 } 53 54 65 public List getAllProperties(URL endpoint, String sCurrUserName, String sPwd) 66 throws RemoteException , ServiceException { 67 Service service = new Service(); 68 Call call = (Call) service.createCall(); 69 70 call.setTargetEndpointAddress(endpoint); 71 call.setOperationName(new QName (OPENHARMONISE_WEBSERVICE_NAMESPACE_URI, 72 "getAllProperties")); 73 74 call.addParameter("username", org.apache.axis.Constants.XSD_STRING, 75 javax.xml.rpc.ParameterMode.IN); 76 call.addParameter("password", org.apache.axis.Constants.XSD_STRING, 77 javax.xml.rpc.ParameterMode.IN); 78 79 QName mtqn = new QName (OPENHARMONISE_WEBSERVICE_NAMESPACE_URI, 80 "ConfigProperty"); 81 call.registerTypeMapping(ConfigProperty.class, mtqn, 82 BeanSerializerFactory.class, BeanDeserializerFactory.class); 83 84 call.setReturnType(org.apache.axis.Constants.SOAP_ARRAY); 85 call.setReturnClass(ArrayList.class); 86 87 List obj = (List) call.invoke(new Object []{sCurrUserName,sPwd}); 88 89 return obj; 90 91 } 92 93 106 public ConfigProperty getProperty(URL endpoint, String sCurrUserName, String sPwd, 107 String sPropName) throws RemoteException , ServiceException { 108 ConfigProperty prop = null; 109 110 List propList = new ArrayList(); 111 112 propList.add(sPropName); 113 114 List props = getProperties(endpoint, sCurrUserName, sPwd, propList); 115 116 if(props != null && props.size() > 0) { 117 prop = (ConfigProperty) props.get(0); 118 } 119 120 return prop; 121 } 122 123 135 public List getProperties(URL endpoint, String sCurrUserName, String sPwd, 136 List propNames) throws RemoteException , ServiceException { 137 Service service = new Service(); 138 Call call = (Call) service.createCall(); 139 140 call.setTargetEndpointAddress(endpoint); 141 call.setOperationName(new QName (OPENHARMONISE_WEBSERVICE_NAMESPACE_URI, 142 "getProperties")); 143 144 call.addParameter("username", org.apache.axis.Constants.XSD_STRING, 145 javax.xml.rpc.ParameterMode.IN); 146 call.addParameter("password", org.apache.axis.Constants.XSD_STRING, 147 javax.xml.rpc.ParameterMode.IN); 148 call.addParameter("propNames", org.apache.axis.Constants.SOAP_ARRAY, 149 javax.xml.rpc.ParameterMode.IN); 150 151 QName mtqn = new QName (OPENHARMONISE_WEBSERVICE_NAMESPACE_URI, 152 "ConfigProperty"); 153 call.registerTypeMapping(ConfigProperty.class, mtqn, 154 BeanSerializerFactory.class, BeanDeserializerFactory.class); 155 156 call.setReturnType(org.apache.axis.Constants.SOAP_ARRAY); 157 call.setReturnClass(ArrayList.class); 158 159 List obj = (List) call.invoke(new Object [] { sCurrUserName,sPwd,propNames }); 160 161 return obj; 162 163 } 164 165 175 public void setProperty(URL endpoint, String sCurrUserName, String sPwd, 176 ConfigProperty prop) throws RemoteException , ServiceException { 177 178 ArrayList props = new ArrayList(); 179 props.add(prop); 180 181 setProperties(endpoint, sCurrUserName, sPwd, props); 182 183 } 184 185 196 public void setProperties(URL endpoint, String sCurrUserName, String sPwd, 197 List props) throws RemoteException , ServiceException { 198 Service service = new Service(); 199 Call call = (Call) service.createCall(); 200 201 call.setTargetEndpointAddress(endpoint); 202 call.setOperationName(new QName (OPENHARMONISE_WEBSERVICE_NAMESPACE_URI, 203 "setProperties")); 204 205 call.addParameter("username", org.apache.axis.Constants.XSD_STRING, 206 javax.xml.rpc.ParameterMode.IN); 207 call.addParameter("password", org.apache.axis.Constants.XSD_STRING, 208 javax.xml.rpc.ParameterMode.IN); 209 call.addParameter("props", org.apache.axis.Constants.SOAP_ARRAY, 210 javax.xml.rpc.ParameterMode.IN); 211 212 QName mtqn = new QName (OPENHARMONISE_WEBSERVICE_NAMESPACE_URI, 213 "ConfigProperty"); 214 call.registerTypeMapping(ConfigProperty.class, mtqn, 215 BeanSerializerFactory.class, BeanDeserializerFactory.class); 216 217 call.setReturnType(org.apache.axis.Constants.XSD_INTEGER); 218 219 call.invoke(new Object [] { sCurrUserName,sPwd,props }); 220 221 } 222 223 233 public void addProperty(URL endpoint, String sCurrUserName, String sPwd, 234 ConfigProperty prop) throws RemoteException , ServiceException { 235 236 ArrayList props = new ArrayList(); 237 props.add(prop); 238 239 addProperties(endpoint, sCurrUserName, sPwd, props); 240 241 } 242 243 253 public void addProperties(URL endpoint, String sCurrUserName, String sPwd, 254 List props) throws RemoteException , ServiceException { 255 Service service = new Service(); 256 Call call = (Call) service.createCall(); 257 258 call.setTargetEndpointAddress(endpoint); 259 call.setOperationName(new QName (OPENHARMONISE_WEBSERVICE_NAMESPACE_URI, 260 "addProperties")); 261 262 call.addParameter("username", org.apache.axis.Constants.XSD_STRING, 263 javax.xml.rpc.ParameterMode.IN); 264 call.addParameter("password", org.apache.axis.Constants.XSD_STRING, 265 javax.xml.rpc.ParameterMode.IN); 266 call.addParameter("props", org.apache.axis.Constants.SOAP_ARRAY, 267 javax.xml.rpc.ParameterMode.IN); 268 269 QName mtqn = new QName (OPENHARMONISE_WEBSERVICE_NAMESPACE_URI, 270 "ConfigProperty"); 271 call.registerTypeMapping(ConfigProperty.class, mtqn, 272 BeanSerializerFactory.class, BeanDeserializerFactory.class); 273 274 call.setReturnType(org.apache.axis.Constants.XSD_INTEGER); 275 276 call.invoke(new Object [] { sCurrUserName,sPwd,props }); 277 278 } 279 280 290 public void removeProperty(URL endpoint, String sCurrUserName, 291 String sPwd, String propName) throws RemoteException , ServiceException { 292 ArrayList props = new ArrayList(); 293 props.add(propName); 294 295 removeProperties(endpoint, sCurrUserName, sPwd, props); 296 } 297 298 309 public void removeProperties(URL endpoint, String sCurrUserName, 310 String sPwd, List propNames) throws RemoteException , ServiceException { 311 Service service = new Service(); 312 Call call = (Call) service.createCall(); 313 314 call.setTargetEndpointAddress(endpoint); 315 call.setOperationName(new QName (OPENHARMONISE_WEBSERVICE_NAMESPACE_URI, 316 "removeProperties")); 317 318 call.addParameter("username", org.apache.axis.Constants.XSD_STRING, 319 javax.xml.rpc.ParameterMode.IN); 320 call.addParameter("password", org.apache.axis.Constants.XSD_STRING, 321 javax.xml.rpc.ParameterMode.IN); 322 call.addParameter("props", org.apache.axis.Constants.SOAP_ARRAY, 323 javax.xml.rpc.ParameterMode.IN); 324 325 QName mtqn = new QName (OPENHARMONISE_WEBSERVICE_NAMESPACE_URI, 326 "ConfigProperty"); 327 call.registerTypeMapping(ConfigProperty.class, mtqn, 328 BeanSerializerFactory.class, BeanDeserializerFactory.class); 329 330 call.setReturnType(org.apache.axis.Constants.XSD_INTEGER); 331 332 call.invoke(new Object [] { sCurrUserName,sPwd,propNames }); 333 334 } 335 336 341 public static void main(String [] args) { 342 try { 343 URL url = new URL ( 344 "http://localhost:7000/webdav/services/ConfigService"); 345 346 ConfigSettingsClient client = new ConfigSettingsClient(); 347 348 List props = client.getAllProperties(url,"super","Tanger1ne"); 349 350 Iterator iter = props.iterator(); 351 List nameList = new ArrayList(); 352 int i =0; 353 while (iter.hasNext()) { 354 ConfigProperty prop = (ConfigProperty) iter.next(); 355 System.out.println("prop " + prop.getName() + ", val = " + 356 prop.getValue()); 357 nameList.add(prop.getName()); 358 } 359 360 props = client.getProperties(url, "super","Tanger1ne",nameList); 361 362 while (iter.hasNext()) { 363 ConfigProperty prop = (ConfigProperty) iter.next(); 364 System.out.println("--- prop " + prop.getName() + ", val = " 365 + prop.getValue()); 366 } 367 368 ArrayList list = new ArrayList(); 369 370 list.add(new ConfigProperty("ERROR_EMAIL_ADDRESS", 371 "bob@simulacramedia.com")); 372 373 client.setProperties(url,"super","Tanger1ne", list); 374 375 } catch (MalformedURLException e) { 376 e.printStackTrace(); 377 } catch (RemoteException e) { 378 e.printStackTrace(); 379 } catch (ServiceException e) { 380 e.printStackTrace(); 381 } 382 } 383 384 } | Popular Tags |