oops replied to wrong eamil.
BJ Freeman sent the following on 9/5/2008 11:57 AM:
> there is supporting code for the xml that also has to be introduced.
> not sure it will work in 4.0.
> if you want Trunk features it is best to use the Trunk.
>
>
> Jacek Wagner sent the following on 9/5/2008 10:57 AM:
>> It is my fault I did not communicate well enough what i wanted. Here is
>> my final attempt.
>>
>> This is what i want : add new product utilizing remote access via SOAP
>>
>> This is what i have: ofbiz has service "createProduct" that requires
>> auth="true"
>>
>> This is what i know: ofbiz services are not Web_services
>>
>> You suggested in previous exchange to created a wrapper in ofbiz (ofbiz
>> wrapper will call createProduct service ) that can be called using soap.
>>
>> I created ofbiz wrapper and when i test thru the webtools (used login
>> admin/ofbiz) it let me add new product, but when i call from the remote
>> client i am getting a message that i have to login to complete transaction.
>> The question is how to login within ofbiz wrapper before calling
>> createProduct implementation.
>>
>> Below the code that logins successfully, but does not pass credentials
>> to the service
>>
>> public static Map createLHSProduct(DispatchContext dctx, Map context) {
>> GenericDelegator delegator = dctx.getDelegator();
>>
>> try {
>> String loginuser;
>> String loginpassword;
>> String productType;
>> String productName;
>>
>> // get the input parameter
>>
>> loginuser = (String) context.get("loginuser");
>> Debug.logInfo("loginuser = " + loginuser, module); loginpassword =
>> (String) context.get("loginpassword");
>> Debug.logInfo("loginpassword = " + loginpassword,module);
>> productType = (String) context.get("productTypeId");
>> Debug.logInfo("productTypeId = " + productType,module); productName
>> = (String) context.get("internalName");
>> Debug.logInfo("internalName = " + productName,module);
>> // login
>> context.put("login.username", loginuser);
>> context.put("login.password", loginpassword);
>> Map loginresult = LoginServices.userLogin(dctx, context);
>> Debug.logInfo("loginresult = " + loginresult,module);
>> //create new product
>> 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) {
>> return ServiceUtil.returnError(ex.getMessage());
>> } catch (Exception ex) {
>> return ServiceUtil.returnError(ex.getMessage());
>> }
>> }
>>
>>
>>
>> BJ Freeman wrote:
>>> there is code already that you can follow the flow.
>>> it save me having to explain what is already used.
>>> you can follow the flow of that code to write you wrapper.
>>>
>>> for instance you are trying to deal with a product.
>>> so if you follow the code flow that creates a product in ofbiz
>>> you will have a template on how to do this in your wrapper.
>>>
>>>
>>> Jacek Wagner sent the following on 9/4/2008 5:41 PM:
>>>
>>>> I am not sure I follow. All what I want from this ofbiz wrapper to
>>>> obtain credential in order to complete adding new product.
>>>> This ofbiz wrapper is being called thru soap and has to be able to login
>>>> and process new product.
>>>>
>>>> BJ Freeman wrote:
>>>>
>>>>> I am assuming that you have read code that already does this operations
>>>>> to pick up what you not doing.
>>>>>
>>>>>
>>>>> BJ Freeman sent the following on 9/4/2008 5:05 PM:
>>>>>
>>>>>
>>>>>> did you check each return Map to check for a "success" message
>>>>>>
>>>>>> Jacek Wagner sent the following on 9/4/2008 3:01 PM:
>>>>>>
>>>>>>> Thank you for the tip. The return map includes error "You must be
>>>>>>> logged in to complete the Create an Product process." I hoped that by
>>>>>>> calling LoginServices.userLogin.....with admin/ofbiz (second task)
>>>>>>> I am
>>>>>>> receiving all credentials I need to complete the task.
>>>>>>> Jacek
>>>>>>>
>>>>>>> BJ Freeman wrote:
>>>>>>>
>>>>>>>> Simple services don't provide exceptions.
>>>>>>>> They do return a Map that has error messages in it.
>>>>>>>> https://demo.hotwaxmedia.com/webtools/control/availableServices?sel_service_name=createProduct
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> take a look at the Out parameters
>>>>>>>> Note this is for
>>>>>>>> org/ofbiz/product/product/ProductServices.xml
>>>>>>>> and uses a map and runsync
>>>>>>>>
>>>>>>>> Jacek Wagner sent the following on 9/4/2008 9:55 AM:
>>>>>>>>
>>>>>>>>
>>>>>>>>> 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());
>>>>>>>>> }
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>>
>>>
>>
>>
>>
>
>
>
>