public Object sendRequest(XmlRpcRequest pRequest) throws XmlRpcException { XmlRpcStreamRequestConfig config = (XmlRpcStreamRequestConfig) pRequest.getConfig(); boolean closed = false; try { ReqWriter reqWriter = newReqWriter(pRequest); writeRequest(reqWriter); InputStream istream = getInputStream(); if (isResponseGzipCompressed(config)) { istream = new GZIPInputStream(istream); } Object result = readResponse(config, istream); closed = true; close(); return result; } catch (IOException e) { throw new XmlRpcException("Failed to read servers response: " + e.getMessage(), e); } catch (SAXException e) { Exception ex = e.getException(); if (ex != null && ex instanceof XmlRpcException) { throw (XmlRpcException) ex; } throw new XmlRpcException("Failed to generate request: " + e.getMessage(), e); } finally { if (!closed) { try { close(); } catch (Throwable ignore) {} } } }
public Object sendRequest(XmlRpcRequest pRequest) throws XmlRpcException { initHttpHeaders(pRequest); return super.sendRequest(pRequest); }
protected Object readResponse(XmlRpcStreamRequestConfig pConfig, InputStream pStream) throws XmlRpcException { InputSource isource = new InputSource(pStream); isource.setEncoding(pConfig.getEncoding()); //jl 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 server's response: " + e.getMessage(), e); } catch (IOException e) { throw new XmlRpcClientException("Failed to read server's response: " + e.getMessage(), e); } if (xp.isSuccess()) { return xp.getResult(); } Throwable t = xp.getErrorCause(); if (t == null) { throw new XmlRpcException(xp.getErrorCode(), xp.getErrorMessage()); } if (t instanceof XmlRpcException) { throw (XmlRpcException) t; } if (t instanceof RuntimeException) { throw (RuntimeException) t; } throw new XmlRpcException(xp.getErrorCode(), xp.getErrorMessage(), t); } }
protected ReqWriter newReqWriter(XmlRpcRequest pRequest) throws XmlRpcException, IOException, SAXException { final XmlRpcHttpClientConfig config = (XmlRpcHttpClientConfig) pRequest.getConfig(); if (isUsingByteArrayOutput(config)) { ByteArrayReqWriter reqWriter = new ByteArrayReqWriter(pRequest); setContentLength(reqWriter.getContentLength()); if (isCompressingRequest(config)) { return new GzipReqWriter(reqWriter); } return reqWriter; } else { return super.newReqWriter(pRequest); } } }
protected ReqWriter newReqWriter(XmlRpcRequest pRequest) throws XmlRpcException, IOException, SAXException { request = pRequest; return super.newReqWriter(pRequest); }
protected ReqWriter newReqWriter(XmlRpcRequest pRequest) throws XmlRpcException, IOException, SAXException { ReqWriter reqWriter = new ReqWriterImpl(pRequest); if (isCompressingRequest((XmlRpcStreamRequestConfig) pRequest.getConfig())) { reqWriter = new GzipReqWriter(reqWriter); } return reqWriter; }
/** 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) {} } } } }
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()); } } }
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 server's response: " + e.getMessage(), e); } catch (IOException e) { throw new XmlRpcClientException("Failed to read server's response: " + e.getMessage(), e); } if (xp.isSuccess()) { return xp.getResult(); } Throwable t = xp.getErrorCause(); if (t == null) { throw new XmlRpcException(xp.getErrorCode(), xp.getErrorMessage()); } if (t instanceof XmlRpcException) { throw (XmlRpcException) t; } if (t instanceof RuntimeException) { throw (RuntimeException) t; } throw new XmlRpcException(xp.getErrorCode(), xp.getErrorMessage(), t); } }
protected ReqWriter newReqWriter(XmlRpcRequest pRequest) throws XmlRpcException, IOException, SAXException { request = pRequest; return super.newReqWriter(pRequest); }
/** * Creates a new instance of {@link ReqWriter}. * @throws XmlRpcException Creating the instance failed. * @throws IOException Creating the instance failed, because * an {@link IOException} occurs. * @throws SAXException Creating the instance failed, because * the request could not be parsed. */ protected ReqWriter newReqWriter(XmlRpcRequest pRequest) throws XmlRpcException, IOException, SAXException { ReqWriter reqWriter = new ReqWriterImpl(pRequest); if (isCompressingRequest((XmlRpcStreamRequestConfig) pRequest.getConfig())) { reqWriter = new GzipReqWriter(reqWriter); } return reqWriter; }
/** 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) {} } } } }
public Object sendRequest(XmlRpcRequest pRequest) throws XmlRpcException { XmlRpcStreamRequestConfig config = (XmlRpcStreamRequestConfig) pRequest.getConfig(); boolean closed = false; try { ReqWriter reqWriter = newReqWriter(pRequest); writeRequest(reqWriter); InputStream istream = getInputStream(); if (isResponseGzipCompressed(config)) { istream = new GZIPInputStream(istream); } Object result = readResponse(config, istream); closed = true; close(); return result; } catch (IOException e) { throw new XmlRpcException("Failed to read server's response: " + e.getMessage(), e); } catch (SAXException e) { Exception ex = e.getException(); if (ex != null && ex instanceof XmlRpcException) { throw (XmlRpcException) ex; } throw new XmlRpcException("Failed to generate request: " + e.getMessage(), e); } finally { if (!closed) { try { close(); } catch (Throwable ignore) {} } } }
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 server's response: " + e.getMessage(), e); } catch (IOException e) { throw new XmlRpcClientException("Failed to read server's response: " + e.getMessage(), e); } if (xp.isSuccess()) { return xp.getResult(); } Throwable t = xp.getErrorCause(); if (t == null) { throw new XmlRpcException(xp.getErrorCode(), xp.getErrorMessage()); } if (t instanceof XmlRpcException) { throw (XmlRpcException) t; } if (t instanceof RuntimeException) { throw (RuntimeException) t; } throw new XmlRpcException(xp.getErrorCode(), xp.getErrorMessage(), t); } }
protected ReqWriter newReqWriter(XmlRpcRequest pRequest) throws XmlRpcException, IOException, SAXException { request = pRequest; return super.newReqWriter(pRequest); }
/** * Creates a new instance of {@link ReqWriter}. * @throws XmlRpcException Creating the instance failed. * @throws IOException Creating the instance failed, because * an {@link IOException} occurs. * @throws SAXException Creating the instance failed, because * the request could not be parsed. */ protected ReqWriter newReqWriter(XmlRpcRequest pRequest) throws XmlRpcException, IOException, SAXException { ReqWriter reqWriter = new ReqWriterImpl(pRequest); if (isCompressingRequest((XmlRpcStreamRequestConfig) pRequest.getConfig())) { reqWriter = new GzipReqWriter(reqWriter); } return reqWriter; }
public Object sendRequest(XmlRpcRequest pRequest) throws XmlRpcException { initHttpHeaders(pRequest); return super.sendRequest(pRequest); }
/** 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) {} } } } }
public Object sendRequest(XmlRpcRequest pRequest) throws XmlRpcException { XmlRpcStreamRequestConfig config = (XmlRpcStreamRequestConfig) pRequest.getConfig(); boolean closed = false; try { ReqWriter reqWriter = newReqWriter(pRequest); writeRequest(reqWriter); InputStream istream = getInputStream(); if (isResponseGzipCompressed(config)) { istream = new GZIPInputStream(istream); } Object result = readResponse(config, istream); closed = true; close(); return result; } catch (IOException e) { throw new XmlRpcException("Failed to read server's response: " + e.getMessage(), e); } catch (SAXException e) { Exception ex = e.getException(); if (ex != null && ex instanceof XmlRpcException) { throw (XmlRpcException) ex; } throw new XmlRpcException("Failed to generate request: " + e.getMessage(), e); } finally { if (!closed) { try { close(); } catch (Throwable ignore) {} } } }
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 server's response: " + e.getMessage(), e); } catch (IOException e) { throw new XmlRpcClientException("Failed to read server's response: " + e.getMessage(), e); } if (xp.isSuccess()) { return xp.getResult(); } Throwable t = xp.getErrorCause(); if (t == null) { throw new XmlRpcException(xp.getErrorCode(), xp.getErrorMessage()); } if (t instanceof XmlRpcException) { throw (XmlRpcException) t; } if (t instanceof RuntimeException) { throw (RuntimeException) t; } throw new XmlRpcException(xp.getErrorCode(), xp.getErrorMessage(), t); } }