protected Object readResponse(XmlRpcStreamRequestConfig pConfig, InputStream pStream) throws XmlRpcException { InputSource isource = new InputSource(pStream); XMLReader xr = newXMLReader(); XmlRpcResponseParser xp; try { xp = new XmlRpcResponseParser(pConfig, getClient().getTypeFactory()); xr.setContentHandler(xp); xr.parse(isource); } catch (SAXException e) { throw new XmlRpcClientException("Failed to parse servers response: " + e.getMessage(), e); } catch (IOException e) { throw new XmlRpcClientException("Failed to read servers response: " + e.getMessage(), e); } if (xp.isSuccess()) { return xp.getResult(); } else { throw new XmlRpcException(xp.getErrorCode(), xp.getErrorMessage()); } } }
/** Writes the requests uncompressed XML data to the given * output stream. Ensures, that the output stream is being * closed. */ public void write(OutputStream pStream) throws XmlRpcException, IOException, SAXException { final XmlRpcStreamConfig config = (XmlRpcStreamConfig) request.getConfig(); try { ContentHandler h = getClient().getXmlWriterFactory().getXmlWriter(config, pStream); XmlRpcWriter xw = new XmlRpcWriter(config, h, getClient().getTypeFactory()); xw.write(request); pStream.close(); pStream = null; } finally { if (pStream != null) { try { pStream.close(); } catch (Throwable ignore) {} } } } }