Examples of XmlRpcResponseParser


Examples of org.apache.xmlrpc.parser.XmlRpcResponseParser

*/
public class ParserTest extends TestCase {
  private Object parseResponse(final String s) throws XmlRpcException, IOException, SAXException, SAXParseException {
    XmlRpcStreamRequestConfig config = new XmlRpcClientConfigImpl();
    XmlRpcClient client = new XmlRpcClient();
    XmlRpcResponseParser parser = new XmlRpcResponseParser(config, client.getTypeFactory());
    XMLReader xr = SAXParsers.newXMLReader();
    xr.setContentHandler(parser);
    try {
      xr.parse(new InputSource(new StringReader(s)));
    } catch (SAXParseException e) {
      throw e;
    }
    Object o = parser.getResult();
    return o;
  }
View Full Code Here

Examples of org.apache.xmlrpc.parser.XmlRpcResponseParser

    }
   
    protected Object unmarshalResponse(Exchange exchange, InputStream stream) throws Exception {
        InputSource isource = new InputSource(stream);
        XMLReader xr = newXMLReader();
        XmlRpcResponseParser xp;
        try {
            xp = new XmlRpcResponseParser(config, typeFactory);
            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);

    }
View Full Code Here

Examples of org.apache.xmlrpc.parser.XmlRpcResponseParser

      pStream = new ByteArrayInputStream(baos.toByteArray());
    }

    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());
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.