SoapFault - faultcode:' 1062' faultstring:'送货方式不可用'

时间:2015-10-26 07:36:53

标签: android soap ksoap2 magento-1.9 android-ksoap2

您好我正在开发一个使用Magento作为后端的Android应用程序,我正在使用magento的SOAP webervice,我已将所有产品,客户和客户地址信息添加到购物车,但是当我尝试添加送货方式时到购物车,我收到此错误

SoapFault - faultcode:' 1062' faultstring:'送货方式不可用'

这是我正在尝试的代码,请帮我解决此问题

SoapObject availableShippingMethods = new SoapObject(MAGENTO_NAMESPACE, "shoppingCartShippingList");
availableShippingMethods.addProperty("sessionId", sessionId);
availableShippingMethods.addProperty("quoteId", quoteId);
env.setOutputSoapObject(availableShippingMethods);
androidHttpTransport.call("", env);
Object resultForAvailableShippingMethods = env.getResponse();
Log.d("AvailableShippingMethods",resultForAvailableShippingMethods.toString());

这将为我们提供此输出

D / AvailableShippingMethods:shoppingCartShippingMethodEntityArray {item = shoppingCartShippingMethodEntity {code = flatrate_error;载体= flatrate; carrier_title =统一费率;价= 0; }; }

下面是将Shipping方法设置为CartId

的代码
 SoapObject shippingmethod = new SoapObject(MAGENTO_NAMESPACE, "shoppingCartShippingMethod");
 shippingmethod.addProperty("sessionId", sessionId);
 shippingmethod.addProperty("quoteId", quoteId);
 shippingmethod.addProperty("shippingMethod", "flatrate_error");//Code for Flatrate shipping method and it is enabled in magento site
 env.setOutputSoapObject(shippingmethod);
 androidHttpTransport.call("", env);
 Log.d("shippingMethod", shippingmethod.toString());
 Object resultforShippingMethod = env.getResponse();
 Log.d("ShippingMethod", resultforShippingMethod.toString());

3 个答案:

答案 0 :(得分:2)

我知道回答为时已晚......但未来可能对某人有所帮助......

问题在于magento soap v2的文档...当我浏览了wsdl链接时,我注意到了以下内容......

<message name="shoppingCartShippingMethodRequest">
<part name="sessionId" type="xsd:string"/>
<part name="quoteId" type="xsd:int"/>
<part name="method" type="xsd:string"/>
<part name="storeId" type="xsd:string"/>
</message>

正如您所见,那里的属性方法。实际上,我们必须添加运输方式...... 所以你必须改变你的代码如下......

SoapObject shippingmethod = new SoapObject(MAGENTO_NAMESPACE,"shoppingCartShippingMethod");
shippingmethod.addProperty("sessionId", sessionId);
shippingmethod.addProperty("quoteId", quoteId);
shippingmethod.addProperty("method", "flatrate_error");
env.setOutputSoapObject(shippingmethod);
androidHttpTransport.call("", env);
Log.d("shippingMethod", shippingmethod.toString());
Object resultforShippingMethod = env.getResponse();
Log.d("ShippingMethod", resultforShippingMethod.toString());

答案 1 :(得分:0)

可能是因为国家ID错误。输入正确的信息后,我会收到两种送货方式(freeshipping_freeshippingflatrate_flatrate)。

答案 2 :(得分:0)

在设置送货方式之前,您需要先设置客户地址&amp;在客户地址中,您需要输入国家/地区ID。