我对Java和Android框架有点新,但是我在做什么我不认为是一个复杂的任务。有一个LAMP XML-RPC服务器返回结构数组(关联数组数组),我一直无法在我的Android项目中成功接收到响应。Java中的XML RPC问题 - 无法创建XML解析:org.xml.sax.SaxNotRecognizedException
我使用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
找到看起来像它,谢谢! – Nigel 2011-08-04 16:45:01