Hi,
Need to return map from java service that you have implemented like

   Map<String, Object> result = ServiceUtil.returnSuccess();
   result.put("FinAccountTypeList", FinAccountTypeList);
   return result;

refer ShoppingCartServices.java or any other *Service*.java.

--
Brajesh Patel


prasanthi_ofbiz wrote:
Hi I have created my own service which is created for returning a list. So I
have added below code in the services_ledger.xml
<service name="getFinAccountType" engine="java" export="true"
        location="org.ofbiz.accounting.finaccount.FinAccountServices"
invoke="getFinAccountType" auth="true">
        <description>parameterizing Financial Account Type</description>
        <log level="info" message="Entered into  getFinAccountType service of
services_ledger....."/>
        <attribute type="String" mode="IN" name="finAccountTypeId"
optional="true" />
        <attribute type="String" mode="IN" name="parentTypeId" optional="true"
/>
        <attribute type="String" mode="IN" name="isRefundable" optional="true"
/>
        <attribute type="String" mode="IN" name="replenishEnumId"
optional="true" />
        <attribute type="String" mode="IN" name="hasTable" optional="true" />
        <attribute type="String" mode="IN" name="description" optional="true"
/>
        <attribute name="FinAccountTypeList" type="List" mode="OUT"
optional="true"/>
</service>
and getFinAccountType functionis written in FinAccountServices.java file

public static List getFinAccountType(DispatchContext dctx, Map context) {
                LocalDispatcher dispatcher = dctx.getDispatcher();
        GenericDelegator delegator = dctx.getDelegator();

        GenericValue userLogin = (GenericValue) context.get("userLogin");
        String finAccountTypeId = (String) context.get("finAccountTypeId");
        String parentTypeId = (String) context.get("parentTypeId");
        String replenishEnumId = (String) context.get("replenishEnumId");
        String isRefundable = (String) context.get("isRefundable");
        String hasTable = (String) context.get("hasTable");
        String description = (String) context.get("description");
        GenericValue finAccount=null;
        Map finAcctg = UtilMisc.toMap("finAccountTypeId",
finAccountTypeId,"description", description,"hasTable",
hasTable,"isRefundable", isRefundable,"replenishEnumId",
replenishEnumId,"parentTypeId", parentTypeId);
List exprs = FastList.newInstance(); if(finAccountTypeId!=null)
        {
                Debug.log("finAccountTypeId Added as a serach parameter");
                 exprs.add(EntityCondition.makeCondition("finAccountTypeId",
EntityOperator.EQUALS, finAccountTypeId));
        }
        if(parentTypeId!=null)
        {
                Debug.log("parentTypeId Added as a serach parameter");
                  exprs.add(EntityCondition.makeCondition("parentTypeId",
EntityOperator.EQUALS, parentTypeId));
        }
        if(replenishEnumId!=null)
        {
                Debug.log("replenishEnumId Added as a serach parameter");
                exprs.add(EntityCondition.makeCondition("replenishEnumId",
EntityOperator.EQUALS, replenishEnumId));
        }
        if(isRefundable!=null)
        {
                Debug.log("isRefundable Added as a serach parameter");
                 exprs.add(EntityCondition.makeCondition("isRefundable",
EntityOperator.EQUALS, isRefundable));
        }
        if(hasTable!=null)
        {
                Debug.log("hasTable Added as a serach parameter");
                exprs.add(EntityCondition.makeCondition("hasTable",
EntityOperator.EQUALS, hasTable));
        }
        if(description!=null)
        {
                Debug.log("description Added as a serach parameter");
                 exprs.add(EntityCondition.makeCondition("description",
EntityOperator.EQUALS, description));
        }
List orderBy = UtilMisc.toList("-finAccountTypeId");
        List FinAccountTypeList = null;
        try {
                FinAccountTypeList = delegator.findList("FinAccountType",
EntityCondition.makeCondition(exprs, EntityOperator.AND), null, orderBy,
null, false);
Debug.log("FinAccountTypeList SIZEE........ "+FinAccountTypeList.size()); Debug.log("FinAccountTypeList+++++++++++++++++"+FinAccountTypeList);
        } catch (GenericEntityException e) {
            Debug.logError(e, module);
} return FinAccountTypeList;
    }


But its giving error as

The Following Errors Occurred:

Error calling event: org.ofbiz.webapp.event.EventHandlerException: Service
invocation error (Service [getFinAccountType] did not return a Map object)


Please let me know the am I missed anything.


Reply via email to