Java中的XML RPC问题 - 无法创建XML解析:org.xml.sax.SaxNotRecognizedException

时间:2011-05-22 17:03:35

标签: java android api xml-rpc

我对Java和Android框架有些新手,但是我正在做的事情并不是一件复杂的事情。有一个LAMP XML-RPC服务器返回一个结构数组(关联数组的数组),我一直无法在我的Android项目中成功接收响应。

我正在使用apache xml-rpc库:

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

这是代码。 XML-RPC服务器是本地安装。我部分难倒,因为我在使用此处的XML-RPC调试器工具时能够得到响应: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());            
        }

XmlRpcException被消息捕获:

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

2 个答案:

答案 0 :(得分:1)

看起来像this

答案 1 :(得分:0)

一种可能的解决方案是更改apache xml-rpc以防止设置这些属性。

详情可在https://stackoverflow.com/a/29421189/2128832

中找到