Package org.apache.xmlrpc.parser

Examples of org.apache.xmlrpc.parser.XmlRpcRequestParser


    }

    private XmlRpcRequestParser parseRequest(final String s) throws XmlRpcException, IOException, SAXException {
        XmlRpcStreamConfig config = new XmlRpcHttpRequestConfigImpl();
        XmlRpcClient client = new XmlRpcClient();
        XmlRpcRequestParser parser = new XmlRpcRequestParser(config, client.getTypeFactory());
        XMLReader xr = SAXParsers.newXMLReader();
        xr.setContentHandler(parser);
        xr.parse(new InputSource(new StringReader(s)));
        return parser;
    }
View Full Code Here


        final String s2 = "<methodResponse><params/></methodResponse>";
        Object o2 = parseResponse(s2);
        assertNull(o2);

        final String s3 = "<methodCall><methodName>foo</methodName></methodCall>";
        XmlRpcRequestParser p3 = parseRequest(s3);
        assertEquals("foo", p3.getMethodName());
        assertNull(p3.getParams());

        final String s4 = "<methodCall><methodName>bar</methodName><params/></methodCall>";
        XmlRpcRequestParser p4 = parseRequest(s4);
        assertEquals("bar", p4.getMethodName());
        assertNotNull(p4.getParams());
        assertTrue(p4.getParams().size() == 0);
    }
View Full Code Here

        XmlRpcServer server = new XmlRpcServer();
        XmlRpcServerConfigImpl serverConfig = new XmlRpcServerConfigImpl();
        serverConfig.setEnabledForExtensions(true);
        server.setConfig(serverConfig);
        XmlRpcRequestParser parser = new XmlRpcRequestParser(serverConfig, new TypeFactoryImpl(server));
        SAXParserFactory spf = SAXParserFactory.newInstance();
        spf.setValidating(false);
        spf.setNamespaceAware(true);
        XMLReader xr = spf.newSAXParser().getXMLReader();
        xr.setContentHandler(parser);
        xr.parse(new InputSource(new StringReader(expect)));
        assertEquals("integerKeyMap", parser.getMethodName());
        List params = parser.getParams();
        assertEquals(1, params.size());
        Map paramMap = (Map) params.get(0);
        assertEquals(1, paramMap.size());
        assertEquals("one", paramMap.get(new Integer(1)));
    }
View Full Code Here

  private static final XmlRpcErrorLogger theErrorLogger = new XmlRpcErrorLogger();
  private XmlRpcErrorLogger errorLogger = theErrorLogger;
 
  protected XmlRpcRequest getRequest(final XmlRpcStreamRequestConfig pConfig,
                     InputStream pStream) throws XmlRpcException {
    final XmlRpcRequestParser parser = new XmlRpcRequestParser(pConfig, getTypeFactory());
    final XMLReader xr = SAXParsers.newXMLReader();
    xr.setContentHandler(parser);
    try {
      xr.parse(new InputSource(pStream));
    } catch (SAXException e) {
      Exception ex = e.getException();
      if (ex != null  &&  ex instanceof XmlRpcException) {
        throw (XmlRpcException) ex;
      }
      throw new XmlRpcException("Failed to parse XML-RPC request: " + e.getMessage(), e);
    } catch (IOException e) {
      throw new XmlRpcException("Failed to read XML-RPC request: " + e.getMessage(), e);
    }
    final List params = parser.getParams();
    return new XmlRpcRequest(){
      public XmlRpcRequestConfig getConfig() { return pConfig; }
      public String getMethodName() { return parser.getMethodName(); }
      public int getParameterCount() { return params == null ? 0 : params.size(); }
      public Object getParameter(int pIndex) { return params.get(pIndex); }
    };
  }
View Full Code Here

        XmlRpcServer server = new XmlRpcServer();
        XmlRpcServerConfigImpl serverConfig = new XmlRpcServerConfigImpl();
        serverConfig.setEnabledForExtensions(true);
        server.setConfig(serverConfig);
        XmlRpcRequestParser parser = new XmlRpcRequestParser(serverConfig, new TypeFactoryImpl(server));
        SAXParserFactory spf = SAXParserFactory.newInstance();
        spf.setValidating(false);
        spf.setNamespaceAware(true);
        XMLReader xr = spf.newSAXParser().getXMLReader();
        xr.setContentHandler(parser);
        xr.parse(new InputSource(new StringReader(expect)));
        assertEquals("integerKeyMap", parser.getMethodName());
        List params = parser.getParams();
        assertEquals(1, params.size());
        Map paramMap = (Map) params.get(0);
        assertEquals(1, paramMap.size());
        assertEquals("one", paramMap.get(new Integer(1)));
    }
View Full Code Here

  private static final Log log = LogFactory.getLog(XmlRpcStreamServer.class);
  private XmlWriterFactory writerFactory = new DefaultXMLWriterFactory();

  protected XmlRpcRequest getRequest(final XmlRpcStreamRequestConfig pConfig,
                     InputStream pStream) throws XmlRpcException {
    final XmlRpcRequestParser parser = new XmlRpcRequestParser(pConfig, getTypeFactory());
    final XMLReader xr = SAXParsers.newXMLReader();
    xr.setContentHandler(parser);
    try {
      xr.parse(new InputSource(pStream));
    } catch (SAXException e) {
      Exception ex = e.getException();
      if (ex != null  &&  ex instanceof XmlRpcException) {
        throw (XmlRpcException) ex;
      }
      throw new XmlRpcException("Failed to parse XML-RPC request: " + e.getMessage(), e);
    } catch (IOException e) {
      throw new XmlRpcException("Failed to read XML-RPC request: " + e.getMessage(), e);
    }
    final List params = parser.getParams();
    return new XmlRpcRequest(){
      public XmlRpcRequestConfig getConfig() { return pConfig; }
      public String getMethodName() { return parser.getMethodName(); }
      public int getParameterCount() { return params == null ? 0 : params.size(); }
      public Object getParameter(int pIndex) { return params.get(pIndex); }
    };
  }
View Full Code Here

    }

    private XmlRpcRequestParser parseRequest(final String s) throws XmlRpcException, IOException, SAXException {
        XmlRpcStreamConfig config = new XmlRpcHttpRequestConfigImpl();
        XmlRpcClient client = new XmlRpcClient();
        XmlRpcRequestParser parser = new XmlRpcRequestParser(config, client.getTypeFactory());
        XMLReader xr = SAXParsers.newXMLReader();
        xr.setContentHandler(parser);
        xr.parse(new InputSource(new StringReader(s)));
        return parser;
    }
View Full Code Here

        final String s2 = "<methodResponse><params/></methodResponse>";
        Object o2 = parseResponse(s2);
        assertNull(o2);

        final String s3 = "<methodCall><methodName>foo</methodName></methodCall>";
        XmlRpcRequestParser p3 = parseRequest(s3);
        assertEquals("foo", p3.getMethodName());
        assertNull(p3.getParams());

        final String s4 = "<methodCall><methodName>bar</methodName><params/></methodCall>";
        XmlRpcRequestParser p4 = parseRequest(s4);
        assertEquals("bar", p4.getMethodName());
        assertNotNull(p4.getParams());
        assertTrue(p4.getParams().size() == 0);
    }
View Full Code Here

  private static final Log log = LogFactory.getLog(XmlRpcStreamServer.class);
  private XmlWriterFactory writerFactory = new DefaultXMLWriterFactory();

  protected XmlRpcRequest getRequest(final XmlRpcStreamRequestConfig pConfig,
                     InputStream pStream) throws XmlRpcException {
    final XmlRpcRequestParser parser = new XmlRpcRequestParser(pConfig, getTypeFactory());
    final XMLReader xr = SAXParsers.newXMLReader();
    xr.setContentHandler(parser);
    try {
      xr.parse(new InputSource(pStream));
    } catch (SAXException e) {
      Exception ex = e.getException();
      if (ex != null  &&  ex instanceof XmlRpcException) {
        throw (XmlRpcException) ex;
      }
      throw new XmlRpcException("Failed to parse XML-RPC request: " + e.getMessage(), e);
    } catch (IOException e) {
      throw new XmlRpcException("Failed to read XML-RPC request: " + e.getMessage(), e);
    }
    final List params = parser.getParams();
    return new XmlRpcRequest(){
      public XmlRpcRequestConfig getConfig() { return pConfig; }
      public String getMethodName() { return parser.getMethodName(); }
      public int getParameterCount() { return params.size(); }
      public Object getParameter(int pIndex) { return params.get(pIndex); }
    };
  }
View Full Code Here

  private static final XmlRpcErrorLogger theErrorLogger = new XmlRpcErrorLogger();
  private XmlRpcErrorLogger errorLogger = theErrorLogger;
 
  protected XmlRpcRequest getRequest(final XmlRpcStreamRequestConfig pConfig,
                     InputStream pStream) throws XmlRpcException {
    final XmlRpcRequestParser parser = new XmlRpcRequestParser(pConfig, getTypeFactory());
    final XMLReader xr = SAXParsers.newXMLReader();
    xr.setContentHandler(parser);
    try {
      xr.parse(new InputSource(pStream));
    } catch (SAXException e) {
      Exception ex = e.getException();
      if (ex != null  &&  ex instanceof XmlRpcException) {
        throw (XmlRpcException) ex;
      }
      throw new XmlRpcException("Failed to parse XML-RPC request: " + e.getMessage(), e);
    } catch (IOException e) {
      throw new XmlRpcException("Failed to read XML-RPC request: " + e.getMessage(), e);
    }
    final List params = parser.getParams();
    return new XmlRpcRequest(){
      public XmlRpcRequestConfig getConfig() { return pConfig; }
      public String getMethodName() { return parser.getMethodName(); }
      public int getParameterCount() { return params == null ? 0 : params.size(); }
      public Object getParameter(int pIndex) { return params.get(pIndex); }
    };
  }
View Full Code Here

TOP

Related Classes of org.apache.xmlrpc.parser.XmlRpcRequestParser

Copyright © 2018 www.massapicom. 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.