hey guys. i have a question about SOAP webservice. i have this piece of code in my service layer:
Optional<Customer> customer=customerRepository.findById(Long.valueOf(perlasIdCheckRequestDTO.getUserId())); if (customer.isEmpty()) { log.info("PerlasService.checkId.NoCustomerException.CustomerId:{}.TransactionId:{}",perlasIdCheckRequestDTO.getUserId(),perlasIdCheckRequestDTO.getTransactionId()); throw new NoCustomerException("No customer with customerId:"+perlasIdCheckRequestDTO.getUserId()); }
Optional<Customer> customer=customerRepository.findById(Long.valueOf(perlasIdCheckRequestDTO.getUserId())); if (customer.isEmpty()) { log.info("PerlasService.checkId.NoCustomerException.CustomerId:{}.TransactionId:{}",perlasIdCheckRequestDTO.getUserId(),perlasIdCheckRequestDTO.getTransactionId()); throw new NoCustomerException("No customer with customerId:"+perlasIdCheckRequestDTO.getUserId()); }
and i have this exception:
@Getterpublic class NoCustomerException extends RuntimeException { public NoCustomerException(String message) { super(message); }}
@Getterpublic class NoCustomerException extends RuntimeException { public NoCustomerException(String message) { super(message); }}
and the exception is later handled by the
RestResponseEntityExceptionHandler
RestResponseEntityExceptionHandler
.
so i have a couple of questions: 1. can i use the same exception? or do i need to create a duplicate one that will only be used for SOAP service? can i reuse the exception from my REST service? 2. how to handle the exceptions in SOAP webservices? i tried googling but honestly didnt understand a thing.