[
https://issues.apache.org/jira/browse/OFBIZ-13303?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Wei Zhang updated OFBIZ-13303:
------------------------------
Summary: Error map is missing in the returned service result (was: Error
map is missing in returned the service result)
> Error map is missing in the returned service result
> ---------------------------------------------------
>
> Key: OFBIZ-13303
> URL: https://issues.apache.org/jira/browse/OFBIZ-13303
> Project: OFBiz
> Issue Type: Bug
> Components: framework/service
> Affects Versions: 24.09.01
> Reporter: Wei Zhang
> Priority: Major
>
> To reproduce :
> # Create a service
> {code:java}
> public static Map<String, Object> returnErrorMapService(DispatchContext dctx,
> Map<String, ?> context) {
> Locale locale = (Locale) context.get("locale");
> Map<String, String> errorMap = new java.util.HashMap<>();
> errorMap.put("my_error_key","my test error message");
> Map<String, Object> result = ServiceUtil.returnError(null,
> null,errorMap,null);
> return result;
> } {code}
> 2. Define the service
> {code:java}
> <service name="testErrorMap" engine="java"
> location="org.apache.ofbiz.common.CommonServices"
> invoke="returnErrorMapService">
> </service> {code}
> 3. Print the service result in CoreEvents.java
> {code:java}
> syncServiceResult = dispatcher.runSync(serviceName, serviceContext);
> for (Map.Entry<String, Object> entry : syncServiceResult.entrySet()) {
> System.out.println("=======331============"+entry.getKey() + " = " +
> entry.getValue());
> } {code}
> 4. Run testErrorMap in webtools->RUN SERVICE
> You should see there is no *errorMessageMap=\{my_error_key=my test error
> message}* in the console log
> To fix it:
> Add the following code to the
> ModelServiceReader.java
> {code:java}
> def = new ModelParam();
> def.setName(ModelService.ERROR_MESSAGE_MAP);
> def.setType("java.util.Map");
> def.setMode(ModelService.OUT_PARAM);
> def.setOptional(true);
> def.setInternal(true);
> service.addParam(def); {code}
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)