Brian
Brian

Reputation: 963

XML RPC problem in Java-- Unable to create the XML parse: org.xml.sax.SaxNotRecognizedException

I'm somewhat new to Java and the Android framework, however what I'm doing I don't consider a complicated task. There is a LAMP XML-RPC server that returns an array of structs (array of associative arrays) and I've been unable to successfully receive the response in my Android project.

I am using the apache xml-rpc library:

import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.client.XmlRpcClient;
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;

Here's the code. The XML-RPC server is a local installation. I'm partially stumped because I have been able to get a response just fine when using the XML-RPC debugger tool found here: http://xmlrpc-debug.sourceforge.net/

        XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();

        try {
            config.setServerURL(new URL("http://192.168.1.125:8886/api"));
        } catch (MalformedURLException e) {
            // TODO Auto-generated catch block
            // shouldn't need this because URL is hardcoded
            e.printStackTrace();
        }

        XmlRpcClient client = new XmlRpcClient();
        client.setConfig(config);

        //The only param is userId. Hardcoded in 1, which is a valid id.
        Vector<Integer> params = new Vector<Integer>();
        params.add( 1 );

        try {
             Object xmlrpc_reponse = client.execute("Api.getUser", params);
            //theres more code here to handle the object and return the result, 
            //but it never gets past the above line before triggering the exception
        } catch (XmlRpcException e) {
             Log.w("xmlrpcproblem", e.getMessage());            
        }

The XmlRpcException is caught with the message:

Unable to create the XML parse: org.xml.sax.SaxNotRecognizedException: http://xml.org/sax/features/external-parameters-entities

Upvotes: 1

Views: 2602

Answers (2)

Steohan
Steohan

Reputation: 526

A possible solution is to change apache xml-rpc to prevent setting these properties.

Details can be found in https://stackoverflow.com/a/29421189/2128832

Upvotes: 0

sbridges
sbridges

Reputation: 25150

Looks like this.

Upvotes: 1

Related Questions