10

Hello i am developing an Android app which uses Magento as the backend and i am using SOAP webervice of magento, I have added all the product , customer and customer address information to the cart , But when i try to add the shipping method to the cart , I am getting this error


SoapFault - faultcode: '1062' faultstring: 'Shipping method is not available'

This is the code i am trying with , Please help me to resolve this

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());

This will give us this output


D/AvailableShippingMethods﹕ shoppingCartShippingMethodEntityArray{item=shoppingCartShippingMethodEntity{code=flatrate_error; carrier=flatrate; carrier_title=Flat Rate; price=0; }; }

below is the code which sets Shipping method to the 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());
Sudhir Belagali
  • 370
  • 1
  • 7
  • 22

3 Answers3

2

I know it is too late to answer... but it may help someone in future...

The problem is in the documentation of magento soap v2... When I have gone through the wsdl link, I have noticed somthing as below...

<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>

As u can see, there's property method. Actually, there we have to add the shipping method... So u have to change ur code as below...

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());
Rishad Appat
  • 1,786
  • 1
  • 15
  • 30
0

It might be because of wrong country ID. After entering correct information I am getting two shipping methods (freeshipping_freeshipping and flatrate_flatrate).

Caleb Kleveter
  • 11,170
  • 8
  • 62
  • 92
0

Before setting shipping method you need to set customer addresses first & in customer addresses you need to enter country id.

Shirish
  • 1
  • 1
  • yes i have done this ,, I have entered "IN" for India ..But still getting the same error , – Sudhir Belagali Nov 11 '15 at 16:12
  • Then please check if you have entered address id or not? Previously I used to get code as "flatrate_error" but now I am getting 2 shipping methods i.e. one is freeshipping_freeshipping & and another as flatrate_flatrate.same I am getting in front end too. – Shirish Nov 11 '15 at 19:52
  • I am using SOAP V2 version , But it is throwing some fault code error while adding customer address info to the cart – Sudhir Belagali Nov 12 '15 at 03:44
  • what error code you are getting while adding customer address info to the cart? – Shirish Nov 12 '15 at 16:33
  • I have added customer address info to the cart except address_id – Sudhir Belagali Nov 12 '15 at 16:38
  • what kind of configuration u kept for shipping methods in magento admin panel – Sudhir Belagali Nov 12 '15 at 16:46
  • 1
    address_id is compulsory and you can fetch it by calling "customerAddressList" method. For testing purpose we kept flat rate and free shipping methods in magento admin panel so we are getting two shipping method when calling "shoppingCartShippingList" method! – Shirish Nov 12 '15 at 20:30
  • btw i am still getting 1062 error after correctly setting customer address so in case you get the output after setting customer address then let me know! – Shirish Nov 14 '15 at 18:00