In android how to send complex array in magento using ksoap2 library?

前端 未结 1 619
有刺的猬
有刺的猬 2021-01-22 17:50

Complex Array Like :

$id = \"value\";

$customer = array(\"key\" => \"value\", \"key\" => \"value\");

$set = $soap->call($sessionID, \'abc.set\', arra         


        
相关标签:
1条回答
  • 2021-01-22 17:56

    Step 1 : In ksoap or ksoap2 no direct support to send Array. so you can create a SoapObject with method name(which you need to create array)

    SoapObject object= new SoapObject(NAMESPACE,"shoppingCartProductEntity");
    object.addProperty("product_id","886");
    object.addProperty("sku","ABC 456-Black-10");
             and more parameters.....
    

    Step 2 : then create arrayType method(optional depends on your WSDL) and add this soapObject to that array Object as a property

    SoapObject EntityArray = new SoapObject(NAMESPACE, "shoppingCartProductEntityArray");
    EntityArray.addProperty("products",object);
    

    Step 3 : finally add the array to your main soap call

    SoapObject request = new SoapObject(NAMESPACE,"shoppingCartProductAdd");
    request.addProperty("sessionId", sessionId);
    request.addProperty("quoteId", cartId);
    request.addProperty("products",EntityArray); //ADDING ARRAY HERE AS A PEOPERTY
    env.setOutputSoapObject(request);
    androidHttpTransport.call(NAMESPACE +"/shoppingCartProductAdd ", env);
    resultSoap = env.getResponse();
    

    NOTE : the steps varies depends on the your WSDL, sometimes you can directly add 1st step object as a parameter, this depends on WSDL.

    0 讨论(0)
提交回复
热议问题