如何在android中使用SOAP API获取带有过滤器的magento订单列表?

问题描述 投票:0回答:2

它始终仅在 Android 中返回已完成的订单。

如何在android中编写这段php代码来获取结果

$filters = array(array(
            'filter' => array(
                array(
                    'key' => 'status',
                    'value' => 'pending'
                ))));

发送soap客户端

request = new SoapObject(NAMESPACE, "salesOrderList");
request.addProperty("sessionId",sessionId );
request.addProperty("filters", filters);
magento soap magento-soap-api
2个回答
1
投票

您可以使用 android 中的 ksoap2-android 库执行以下操作

// NAMESPACE - specify your namespace
// sessionId - get by calling the login web service
// SALES_ORDER_LIST - web service to get sales order list

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = false;
envelope.xsd = SoapSerializationEnvelope.XSD;
envelope.enc = SoapSerializationEnvelope.ENC;

SoapObject entity = new SoapObject(NAMESPACE, "associativeEntity");
entity.addProperty("key", "status");
entity.addProperty("value", "processing");

SoapObject filter = new SoapObject(NAMESPACE, "associativeArray");
array.addProperty("associativeEntity", entity);

SoapObject filters = new SoapObject(NAMESPACE, "filters");
filter.addProperty("filter", filters);

SoapObject salesOrderList = new SoapObject(NAMESPACE, "salesOrderList");
requestCart.addProperty("sessionId", sessionId);
requestCart.addProperty("filters", filters);

env.setOutputSoapObject(salesOrderList);
androidHttpTransport.call(SALES_ORDER_LIST, envelope);

result = env.getResponse();
Log.d("List of Products", result.toString());

0
投票

使用 ksoap2-android 库对 Magento Soap 进行复杂过滤器

           SoapSerializationEnvelope env = new SoapSerializationEnvelope(
                    SoapEnvelope.VER11);

            env.dotNet = false;
            env.xsd = SoapSerializationEnvelope.XSD;
            env.enc = SoapSerializationEnvelope.ENC;

            SoapObject request = new SoapObject(NAMESPACE,
                    "salesOrderList");

            SoapObject value = new SoapObject(NAMESPACE, "associativeEntity");
            // complex filter , for more info http://devdocs.magento.com/guides/m1x/api/soap/sales/salesOrder/sales_order.list.html
            value.addProperty("key", "in");
            value.addProperty("value", "18700051200102,19200135301230");

            SoapObject complexFilter = new SoapObject(NAMESPACE, "complexFilter");
            complexFilter.addProperty("key", "increment_id");
            complexFilter.addProperty("value", value);

            SoapObject filterArray = new SoapObject(NAMESPACE, "complexFilterArray");
            filterArray.addProperty("item",complexFilter);

            SoapObject filters=new SoapObject(NAMESPACE, "filters");
            filters.addProperty("complex_filter", filterArray);

            request.addProperty("sessionId", params[0]);
            request.addProperty("filters", filters);

            env.setOutputSoapObject(request);

            HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);

            androidHttpTransport.call("", env);
            SoapObject result = (SoapObject) env.getResponse();

            Log.i("MessageOrderList", result.toString());
© www.soinside.com 2019 - 2024. All rights reserved.