Android Studio:XmlRpcClientException 无法解析服务器响应:意外的非空白字符数据
Android Studio: XmlRpcClientException Failed to parse servers response: Unexpected non-whitespace character data
所以我正在尝试将我的应用程序与 android studio 中的 odoo 数据库连接起来,并使用 odoo 外部 API "XML-RPC" 从数据库中获取数据,我能够连接并成功获得用户 ID,我也能够正常搜索和创建,但是当我从数据库中读取任何内容时,此异常一直显示。我找不到他能帮我的任何事情。
那么请问有谁可以告诉我我在哪里做的吗?
这是我的代码:
public class MainActivity extends AppCompatActivity {
final String db = "BTP_p",
username = "admin",
password = "_chantier";
final String url ="http://sogesi.hopto.org";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
new DemoTask().execute(url);
}
class DemoTask extends AsyncTask<String, Void, Integer> {
@Override
protected Integer doInBackground(final String... url) {
final XmlRpcClient client = new XmlRpcClient();
final XmlRpcClientConfigImpl common_config = new XmlRpcClientConfigImpl();
try {
//Testé l'authentification
common_config.setServerURL(
new URL(String.format("%s/xmlrpc/2/common", url)));
int uid = (int)client.execute(
common_config, "authenticate", asList(
db, username, password, emptyMap()));
Log.d("result", "*******************************************************************");
Log.d("uid = ", Integer.toString(uid));
//Testé la liste des recordes d'une table
final XmlRpcClient models = new XmlRpcClient() {{
setConfig(new XmlRpcClientConfigImpl() {{
setServerURL(new URL(String.format("%s/xmlrpc/2/object",url)));
}});
}};
final List id = asList((Object[])models.execute(
"execute_kw", asList(
db, uid, password,
"project.chantier", "search",
asList(asList(
asList("state", "=", "en_cour"))),
new HashMap() {{
put("limit", 1);
}}
)));
//this is the ligne where the exception is rising
final Map record = (Map)((Object[])models.execute(
"execute_kw", asList(
db, uid, password,
"project.chantier", "read",
asList(id)
)
))[0];
return (Integer) uid;
} catch (MalformedURLException e) {
Log.d("MalformedURLException", "*********************************************************");
Log.d("MalformedURLException", e.toString());
} catch (XmlRpcException e) {
e.printStackTrace();
}
return null;
}
protected void onPostExecute(Void result) {
// TODO: do something with the feed
}
}
}
This is the exception
在我的例子中,我必须下载并导入这三个库:
exist-dependency-ws-commons-util-1.0.2.jar
xmlrpc-client-3.1.jar
xmlrpc-common-3.1.jar
所以我正在尝试将我的应用程序与 android studio 中的 odoo 数据库连接起来,并使用 odoo 外部 API "XML-RPC" 从数据库中获取数据,我能够连接并成功获得用户 ID,我也能够正常搜索和创建,但是当我从数据库中读取任何内容时,此异常一直显示。我找不到他能帮我的任何事情。 那么请问有谁可以告诉我我在哪里做的吗?
这是我的代码:
public class MainActivity extends AppCompatActivity {
final String db = "BTP_p",
username = "admin",
password = "_chantier";
final String url ="http://sogesi.hopto.org";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
new DemoTask().execute(url);
}
class DemoTask extends AsyncTask<String, Void, Integer> {
@Override
protected Integer doInBackground(final String... url) {
final XmlRpcClient client = new XmlRpcClient();
final XmlRpcClientConfigImpl common_config = new XmlRpcClientConfigImpl();
try {
//Testé l'authentification
common_config.setServerURL(
new URL(String.format("%s/xmlrpc/2/common", url)));
int uid = (int)client.execute(
common_config, "authenticate", asList(
db, username, password, emptyMap()));
Log.d("result", "*******************************************************************");
Log.d("uid = ", Integer.toString(uid));
//Testé la liste des recordes d'une table
final XmlRpcClient models = new XmlRpcClient() {{
setConfig(new XmlRpcClientConfigImpl() {{
setServerURL(new URL(String.format("%s/xmlrpc/2/object",url)));
}});
}};
final List id = asList((Object[])models.execute(
"execute_kw", asList(
db, uid, password,
"project.chantier", "search",
asList(asList(
asList("state", "=", "en_cour"))),
new HashMap() {{
put("limit", 1);
}}
)));
//this is the ligne where the exception is rising
final Map record = (Map)((Object[])models.execute(
"execute_kw", asList(
db, uid, password,
"project.chantier", "read",
asList(id)
)
))[0];
return (Integer) uid;
} catch (MalformedURLException e) {
Log.d("MalformedURLException", "*********************************************************");
Log.d("MalformedURLException", e.toString());
} catch (XmlRpcException e) {
e.printStackTrace();
}
return null;
}
protected void onPostExecute(Void result) {
// TODO: do something with the feed
}
}
}
This is the exception
在我的例子中,我必须下载并导入这三个库:
exist-dependency-ws-commons-util-1.0.2.jar
xmlrpc-client-3.1.jar
xmlrpc-common-3.1.jar