你好,我正在开发一个使用 Magento 作为后端的 Android 应用程序,我正在使用 magento 的 SOAP webervice,我已经将所有产品、客户和客户地址信息添加到购物车,但是当我尝试添加运输方式时到购物车,我收到这个错误
SoapFault - 错误代码:'1062' 错误字符串:'送货方式不可用'
这是我正在尝试的代码,请帮我解决这个问题
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;承运人=工时; 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());
最佳答案
我知道现在回答为时已晚......但它可能会在未来帮助某人......
问题出在 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());
关于android - SoapFault - 故障代码 : '1062' faultstring: 'Shipping method is not available' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33340649/