The following is an ofbiz wrapper that performs three tasks: login, get description for a given product, create new product

When run from webtools (performs successfully all three tasks. when called as a soap performs successfully login & get descriptions for a given product. It also run thru create new product, but does not create new product neither throw any exception(s).

Wondering Jacek
public static Map createLHSProduct(DispatchContext dctx, Map context) {
       GenericDelegator delegator = dctx.getDelegator();

       try {
           String productId;
           String loginuser;
           String loginpassword;
           String productType;
           String productName;

           // get the input parameter

           productId = (String) context.get("productId");
Debug.logInfo("productId = " + productId, module); loginuser = (String) context.get("loginuser"); Debug.logInfo("loginuser = " + loginuser, module); //prints to the console or console.log
           loginpassword = (String) context.get("loginpassword");
Debug.logInfo("loginpassword = " + loginpassword, module); //prints to the console or console.log
           productType = (String) context.get("productTypeId");
Debug.logInfo("productTypeId = " + productType, module); //prints to the console or console.log
           productName = (String) context.get("internalName");
Debug.logInfo("internalName = " + productName, module); //prints to the console or console.log

// login
           context.put("login.username", loginuser);
           context.put("login.password", loginpassword);
           Map loginresult = LoginServices.userLogin(dctx, context);
Debug.logInfo("loginresult = " + loginresult, module); //prints to the console or console.log

//get description for a given product
Map queryResult = delegator.findByPrimaryKey("Product", UtilMisc.toMap("productId", productId));
           Map result = UtilMisc.toMap("description", productId);
           if (queryResult != null) {
               result.put("description", queryResult.get("description"));
           }

//create new product
           context.remove("productId");
           context.put("productTypeId", productType);
context.put("internalName", productName); Map productresult = SimpleMethod.runSimpleService(
                   "org/ofbiz/product/product/ProductServices.xml",
                   "createProduct", dctx, context);

           return result;

} catch (GenericEntityException ex) {//required if you use delegator in Java
           return ServiceUtil.returnError(ex.getMessage());
       } catch (Exception ex) {//required if you use delegator in Java
           return ServiceUtil.returnError(ex.getMessage());
       }
   }

Reply via email to