1 23 24 package org.infoglue.deliver.util.webservices; 25 26 import java.util.Vector ; 27 28 import org.apache.log4j.Logger; 29 import org.apache.xmlrpc.XmlRpc; 30 import org.apache.xmlrpc.XmlRpcClient; 31 32 33 38 39 public class XMLRPCHelper 40 { 41 private final static Logger logger = Logger.getLogger(XMLRPCHelper.class.getName()); 42 43 private String serviceUrl = ""; 44 private String method = ""; 45 private Vector parameters = new Vector (); 46 private Object result = null; 47 48 private String errorCode = "0"; 49 private String errorMessage = "Ok"; 50 51 54 55 public XMLRPCHelper() 56 { 57 } 58 59 public void makeCall() 60 { 61 try 62 { 63 XmlRpcClient xmlrpc = new XmlRpcClient(serviceUrl); 64 XmlRpc.setEncoding("ISO-8859-1"); 65 70 this.result = xmlrpc.execute(this.method, this.parameters); 72 73 logger.info("result:" + result); 74 } 75 catch(Exception e) 76 { 77 this.errorCode = "1"; 78 this.errorMessage = "An error occurred:" + e.getMessage(); 79 logger.warn("An error occurred:" + e.getMessage(), e); 80 } 81 } 82 83 public void setParameters(Vector parameters) 84 { 85 this.parameters = parameters; 86 } 87 88 public Vector getParameters() 89 { 90 return this.parameters; 91 } 92 93 public String getServiceUrl() 94 { 95 return serviceUrl; 96 } 97 98 public void setServiceUrl(String serviceUrl) 99 { 100 this.serviceUrl = serviceUrl; 101 } 102 103 public Object getResult() 104 { 105 return this.result; 106 } 107 108 public String getErrorCode() 109 { 110 return this.errorCode; 111 } 112 113 public String getErrorMessage() 114 { 115 return this.errorMessage; 116 } 117 118 public void setErrorCode(String errorCode) 119 { 120 this.errorCode = errorCode; 121 } 122 123 public void setErrorMessage(String errorMessage) 124 { 125 this.errorMessage = errorMessage; 126 } 127 128 public String getMethod() 129 { 130 return this.method; 131 } 132 133 public void setMethod(String method) 134 { 135 this.method = method; 136 } 137 138 } | Popular Tags |