gpt4 book ai didi

java - 无法使用 XMLRPC 使用 sales_order.list 获取销售数据

转载 作者:行者123 更新时间:2023-12-01 15:15:58 25 4
gpt4 key购买 nike

我不知道我调用 Magento 商店的 sales_order.list 方法的方式有什么问题。我从 Magento 商店得到的响应为零。实际上,商店包含 5 个销售订单.
我正在使用的代码如下。
请有人帮助我,因为这是一个长期问题,我无法找到解决方案。提前致谢。

import java.util.HashMap;
import org.xmlrpc.android.XMLRPCClient;
import org.xmlrpc.android.XMLRPCException;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

public class Dashboard extends Activity{
Button loadProductList,loadSalesOrders;
XMLRPCClient client;
private Context mContext;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.dashboard);
client = new XMLRPCClient( "http://192.168.1.237/machinetest/index.php/api/xmlrpc");
mContext=Dashboard.this;
loadSalesOrders();
}

public void loadSalesOrders()
{
Object[] productsGroupList = {" "};
try
{
productsGroupList = (Object[])client.callEx( "call", new Object[] {Utils.sessionId, "sales_order.list"});
}
catch (XMLRPCException e) {e.printStackTrace();}
Toast.makeText(mContext, productsGroupList.toString(), Toast.LENGTH_LONG).show();
for(Object o :productsGroupList)
{
Log.i( "**APP_INFO", o.getClass().getName());
HashMap map = (HashMap)o;
Log.i( "Products Keys", "Keys"+map.keySet().toString());

}
}

}

最佳答案

我正在使用相同的代码,它对我有用。您获得了正确的 session ID 吗?

也许 XMLRPC 库存在一些问题。 Here XMLRPC 库的两个更新类:XMLRPCSerializer.javaIXMLRPCSerializer.java。将代码中的这两个文件替换掉就可以了。

    String sessionId = "";
client = new XMLRPCClient(URL);
try {
sessionId = (String)client.call("login", "tester", "tester");
Log.d("MY_XMLRPC_SUCCESS_SESSION_ID", sessionId);
}
catch (XMLRPCException e) {
Log.d("MY_XMLRPCException_MSG", e.getMessage());
}

Object[] customerOrderList = null;
try {
customerOrderList = (Object[])client.callEx("call", new Object[]{sessionId, "sales_order.list"});
} catch (Exception e) {
Log.d("APP_INFO", "Exception: " + e.getMessage());
}

关于java - 无法使用 XMLRPC 使用 sales_order.list 获取销售数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11610800/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com