如何使用Android中的Magento SOAP API v2方法shoppingCartCustomerAddresses将送货地址设置为购物车报价?

时间:2015-04-20 05:20:54

标签: android magento soap ksoap2

如何使用kso​​ap2 Android库在Android中使用Magento SOAP API v2方法shoppingCartCustomerAddresses将发货地址设置为购物车报价? 当我设置送货地址&帐单邮寄地址,帐单邮寄地址设置但不是送货地址。设置地址时,我得到了结果。使用PHP正确设置地址,因为当我调用shoppingCartInfo方法时,我得到了正确的响应。我认为以下格式是错误的,任何人都可以告诉我正确的格式。以下是我的尝试:

                               SoapObject item = new SoapObject(NAMESPACE, "shoppingCartCustomerAddressEntity");
                               PropertyInfo pinfo = new PropertyInfo();

                                pinfo.setName("mode");
                                pinfo.setValue("shipping");
                                pinfo.setType(String.class);
                                item.addProperty(pinfo);                    
                                pinfo = new PropertyInfo();
                                pinfo.setName("firstname");
                                pinfo.setValue(firstName);
                                pinfo.setType(String.class);
                                item.addProperty(pinfo);

                                Log.i("FIRST NAME 1", firstName);

                                pinfo = new PropertyInfo();
                                pinfo.setName("lastname");
                                pinfo.setValue(lastName);
                                pinfo.setType(String.class);
                                item.addProperty(pinfo);

                                Log.i("LAST NAME 1", lastName);

                                pinfo = new PropertyInfo();
                                pinfo.setName("company");
                                pinfo.setValue(company1);
                                pinfo.setType(String.class);
                                item.addProperty(pinfo);

                                Log.i("COMPANY 1", company1);

                                pinfo = new PropertyInfo();
                                pinfo.setName("street");
                                pinfo.setValue(street1);
                                pinfo.setType(String.class);
                                item.addProperty(pinfo);

                                Log.i("STREET 1", street1);

                                pinfo = new PropertyInfo();
                                pinfo.setName("city");
                                pinfo.setValue(city1);
                                pinfo.setType(String.class);
                                item.addProperty(pinfo);

                                Log.i("CITY 1", city1);

                                pinfo = new PropertyInfo();
                                pinfo.setName("region");
                                pinfo.setValue(region1);
                                pinfo.setType(String.class);
                                item.addProperty(pinfo);

                                Log.i("REGION 1", region1);

                                pinfo = new PropertyInfo();
                                pinfo.setName("postcode");
                                pinfo.setValue(postcode1);
                                pinfo.setType(String.class);
                                item.addProperty(pinfo);

                                Log.i("POST CODE 1", postcode1);

                                pinfo = new PropertyInfo();
                                pinfo.setName("country_id");
                                pinfo.setValue(countryId1);
                                pinfo.setType(String.class);
                                item.addProperty(pinfo);

                                Log.i("COUNTRY ID 1", countryId1);

                                pinfo = new PropertyInfo();
                                pinfo.setName("telephone");
                                pinfo.setValue(telephone1);
                                pinfo.setType(String.class);
                                item.addProperty(pinfo);

                                Log.i("TELEPHONE 1", telephone1);

                                pinfo = new PropertyInfo();
                                pinfo.setName("fax");
                                pinfo.setValue(fax1);
                                pinfo.setType(String.class);
                                item.addProperty(pinfo);

                                Log.i("FAX 1", fax1);

                                pinfo = new PropertyInfo();
                                pinfo.setName("is_default_shipping");
                                pinfo.setValue(0);
                                pinfo.setType(Integer.class);
                                item.addProperty(pinfo);

                                pinfo = new PropertyInfo();
                                pinfo.setName("is_default_billing");
                                pinfo.setValue(1);
                                pinfo.setType(Integer.class);
                                item.addProperty(pinfo);

                               SoapObject entityArray = new SoapObject(NAMESPACE, "shoppingCartCustomerAddressEntityArray");

                                entityArray.addProperty("customer",item);

                                   SoapObject item1 = new SoapObject(NAMESPACE, "shoppingCartCustomerAddressEntity");

                                    pinfo.setName("mode");
                                    pinfo.setValue("billing");
                                    pinfo.setType(String.class);
                                   item1.addProperty(pinfo);

                                    pinfo = new PropertyInfo();
                                    pinfo.setName("firstname");
                                    pinfo.setValue(firstName);
                                    pinfo.setType(String.class);
                                    item1.addProperty(pinfo);

                                    Log.i("FIRST NAME 2", firstName);

                                    pinfo = new PropertyInfo();
                                    pinfo.setName("lastname");
                                    pinfo.setValue(lastName);
                                    pinfo.setType(String.class);
                                    item1.addProperty(pinfo);

                                    Log.i("LAST NAME 2", lastName);

                                    pinfo = new PropertyInfo();
                                    pinfo.setName("company");
                                    pinfo.setValue(company2);
                                    pinfo.setType(String.class);
                                    item1.addProperty(pinfo);

                                    Log.i("COMPANY 2", company2);

                                    pinfo = new PropertyInfo();
                                    pinfo.setName("street");
                                    pinfo.setValue(street2);
                                    pinfo.setType(String.class);
                                    item1.addProperty(pinfo);

                                    Log.i("STREET 2", street2);

                                    pinfo = new PropertyInfo();
                                    pinfo.setName("city");
                                    pinfo.setValue(city2);
                                    pinfo.setType(String.class);
                                    item1.addProperty(pinfo);

                                    Log.i("CITY 2", city2);

                                    pinfo = new PropertyInfo();
                                    pinfo.setName("region");
                                    pinfo.setValue(region2);
                                    pinfo.setType(String.class);
                                    item1.addProperty(pinfo);

                                    Log.i("REGION 2", region2);

                                    pinfo = new PropertyInfo();
                                    pinfo.setName("postcode");
                                    pinfo.setValue(postcode2);
                                    pinfo.setType(String.class);
                                    item1.addProperty(pinfo);

                                    Log.i("POST CODE 2", postcode2);

                                    pinfo = new PropertyInfo();
                                    pinfo.setName("country_id");
                                    pinfo.setValue(countryId2);
                                    pinfo.setType(String.class);
                                    item1.addProperty(pinfo);

                                    Log.i("COUNTRY ID 2", countryId2);

                                    pinfo = new PropertyInfo();
                                    pinfo.setName("telephone");
                                    pinfo.setValue(telephone2);
                                    pinfo.setType(String.class);
                                    item1.addProperty(pinfo);

                                    Log.i("TELEPHONE 2", telephone2);

                                    pinfo = new PropertyInfo();
                                    pinfo.setName("fax");
                                    pinfo.setValue(fax2);
                                    pinfo.setType(String.class);
                                    item1.addProperty(pinfo);

                                    Log.i("FAX 2", fax2);

                                    pinfo = new PropertyInfo();
                                    pinfo.setName("is_default_billing");
                                    pinfo.setValue(0);
                                    pinfo.setType(Integer.class);
                                    item1.addProperty(pinfo);

                                    entityArray.addProperty("customer",item1);

                                SoapObject request = new SoapObject(NAMESPACE, "shoppingCartCustomerAddresses");
                                request.addProperty("sessionId", MainActivity.sessionId);
                                request.addProperty("quoteId", getCartId());
                                request.addProperty("customer",entityArray);
                                request.addProperty("storeId", storeId);

                                MainActivity.env.setOutputSoapObject(request);

                                MainActivity.androidHttpTransport.call("", MainActivity.env);

                                Boolean customerAddressAdded = (Boolean) MainActivity.env.getResponse();

NAMESPACE值为"urn:Magento"

以下是shoppingCartInfo方法响应(仅相关部分):

shipping_address=shoppingCartAddressEntity{
created_at=2015-04-20 04:46:09;
updated_at=2015-04-20 04:46:38;
customer_id=93; 
save_in_address_book=0; 
address_type=shipping; 
same_as_billing=1; 
free_shipping=0; 
weight=0; 
}; 
billing_address=shoppingCartAddressEntity{
created_at=2015-04-20 04:46:09; 
updated_at=2015-04-20 04:46:22; 
customer_id=93; 
save_in_address_book=0; 
address_type=billing; 
email=osama@example.com; 
firstname=abc; 
lastname=xyz; 
company=testing; 
street=testing; 
city=Mumbai; 
region=testing; 
postcode=123456; 
country_id=IN; 
telephone=1234567890; 
same_as_billing=0; 
free_shipping=0; 
weight=0; 
}; 

Shipping to multiple addressesyes &安培; Maximum Qty Allowed for Shipping to Multiple Addresses 100也是{{1}} 在Magento System-> Configuration-> SALES-> Shipping shipping。

我不知道我在哪里错误地认为送货地址没有设置为购物车报价。请帮帮我。

1 个答案:

答案 0 :(得分:0)

我得到了答案。诀窍就是扭转地址的顺序。