cancel
Showing results for 
Search instead for 
Did you mean: 

Magento Soap + Java

Magento Soap + Java

 
I'm trying to CREATE the cart via Soap with Java, to this test code , the budget is created and inserted into the table , but add the WHEN PRODUCT nothing happens and NOT Returns error.


 public static void main(String[] args) throws MalformedURLException {

        MagentoService service = new MagentoService();

        PortType port = service.getPort();

        System.out.println(service.getServiceName());
        System.err.println(port);

        LoginParam loginParam = new LoginParam();
        loginParam.setUsername(USER);
        loginParam.setApiKey(API_KEY);

        LoginResponseParam session = port.login(loginParam);
        String sessionId = session.getResult();
        System.out.println("sessionId : " + sessionId);

        StoreListRequestParam param = new StoreListRequestParam();
        param.setSessionId(sessionId);

        StoreListResponseParam storeListRespParam = port.storeList(param);
        StoreEntityArray storeEntityArray = storeListRespParam.getResult();
        List<StoreEntity> stores = storeEntityArray.getComplexObjectArray();
        System.out.println(">>>> stores " + stores.size());

        ShoppingCartCreateRequestParam shoppingCartCreateRequestParam = new ShoppingCartCreateRequestParam();
        shoppingCartCreateRequestParam.setSessionId(sessionId);
        shoppingCartCreateRequestParam.setStore("1");

        ShoppingCartCreateResponseParam resp = port.shoppingCartCreate(shoppingCartCreateRequestParam);
        int quoteId = resp.getResult();
        System.out.println(">>>> quoteId " + quoteId);

        ShoppingCartProductAddRequestParam prodcutAddParam = new ShoppingCartProductAddRequestParam();

        ShoppingCartProductEntityArray array = new ShoppingCartProductEntityArray();
        ShoppingCartProductEntity produto = new ShoppingCartProductEntity();
        produto.setProductId("1");
        produto.setSku("D15");
        produto.setQty(1.00);
        produto.setLinks(null);
        produto.setBundleOption(null);
        produto.setBundleOptionQty(null);
        produto.setOptions(null);

        array.getComplexObjectArray().add(produto);
        prodcutAddParam.setProductsData(array);
        prodcutAddParam.setQuoteId(quoteId);
        prodcutAddParam.setSessionId(sessionId);
        prodcutAddParam.setStore("1");

        System.out.println("product id  " + array.getComplexObjectArray().get(0).getProductId());
        System.out.println("product sku " + array.getComplexObjectArray().get(0).getSku());
        System.out.println("product qty " + array.getComplexObjectArray().get(0).getQty());
        System.out.println("quoteId     " + prodcutAddParam.getQuoteId());
        System.out.println("SessionId   " + prodcutAddParam.getSessionId());
        System.out.println("Store       " + prodcutAddParam.getStore());

        ShoppingCartProductAddResponseParam prodAddResult = new ShoppingCartProductAddResponseParam();
        System.out.println("product added? " + prodAddResult.isResult()); // RETORNA FALSO

        EndSessionParam endSessionParam = new EndSessionParam();
        endSessionParam.setSessionId(sessionId);
        port.endSession(endSessionParam);
    }

}