Handling Errors in the Published Business Service
The published business service class is the JD Edwards EnterpriseOne object that is exposed as a web service. Upon invocation, the published business service returns either a value object that contains data and warning messages, or it throws a BusinessServiceException that contains all errors and warnings that occurred during business processing. The published business service throws BusinessServiceException if any messages of the type error occur in the collection of messages that are returned from the call to the business service method. System errors and database failures are thrown as runtime exceptions. A runtime exception is not handled, but it will cause the published business service to fail and return to the original caller. Throwing an exception causes any database operations that were performed between the default transaction boundaries to roll back, and an error message is sent to the log files.
This code sample shows how to handle errors in the published business service:
E1MessageList messages = AddressBookProcessor.addAddress Book(context, connection, internalVO); //published business service will send either warnings in the Confirm Value Object or throw a published business service exception. //a return status of 2 is an error, throw the exception if (messages.hasErrors()) { //get the string representation of all the messages //RI: Error Handling String error = messages.getMessagesAsString(); //Throw new BusinessServiceException(error); throw new BusinessServiceException(error, context); } //exception was not thrown, so create the confirm VO from internal VO ConfirmAddAddressBook confirmVO = new ConfirmAddAddressBook (internalVO); confirmVO.setE1MessageList(messages); //return confirm VO, filled with return values and messages return confirmVO;