use of org.apache.xmlrpc.client.XmlRpcClient in project cloudstack by apache.
the class ConnectionTest method callTimeoutInSec.
@Override
public Object callTimeoutInSec(String method, List<?> params, int timeout, boolean debug) throws XmlRpcException {
XmlRpcStreamConfig config = new XmlRpcHttpRequestConfigImpl();
XmlRpcClient client = new XmlRpcClient();
client.setTypeFactory(new RpcTypeFactory(client));
XmlRpcResponseParser parser = new XmlRpcResponseParser((XmlRpcStreamRequestConfig) config, client.getTypeFactory());
XMLReader xr = SAXParsers.newXMLReader();
xr.setContentHandler(parser);
try {
String result = null;
if (getMethodResponse(method) != null) {
result = getMethodResponse(method);
LOGGER.debug("methodresponse call: " + method + " - " + params);
LOGGER.trace("methodresponse reply: " + result);
}
if (result == null && multiRes.size() >= 0) {
result = getResult();
LOGGER.debug("getresult call: " + method + " - " + params);
LOGGER.trace("getresult reply: " + result);
}
xr.parse(new InputSource(new StringReader(result)));
} catch (Exception e) {
throw new XmlRpcException("Exception: " + e.getMessage(), e);
}
if (parser.getErrorCode() != 0) {
throw new XmlRpcException("Fault received[" + parser.getErrorCode() + "]: " + parser.getErrorMessage());
}
return parser.getResult();
}
Aggregations