how to return multiple objects in SOAP webservice?

hey guys. im developing SOAP webservice in java and i have a question. there are two operations checkId and createSale. and there are CheckIdRequestDTO, CheckIdResponseDTO, CreateSaleRequestDTO, CreateSaleResponseDTO. when validating checkId request and there are some errors, i set needed CheckIdResponseDTO fields to needed values and return the DTO and everything is fine. so my endpoint returns CheckIdResponseDTO in both cases: if its ok, or theres an error. But now im having trouble with createSale request. im validating CreateSaleRequestDTO, and if theres an error i dont have anything to return. I was thinking about constructing something like CreateSaleRequestErrorDTO. but then my endpoint cant return it. this is my endpoint so far:
@Endpoint
@Validated
public class PerlasEndpoint {
@Autowired
PerlasService perlasService;
private static final String SOAP_NAMESPACE="http://mycompany.lt/soap-web-service";

@PayloadRoot(namespace = SOAP_NAMESPACE,localPart = "idCheckRequest")
@ResponsePayload
public PerlasCheckIdResponseDTO checkId(@Valid @RequestPayload PerlasCheckIdRequestDTO perlasCheckIdRequestDTO) {
Optional<PerlasCheckIdResponseDTO> validationResult=perlasService.validateCheckIdRequest(perlasCheckIdRequestDTO, "CHECK ID");

if (validationResult.isPresent()) {
return validationResult.get();
}

PerlasCheckIdResponseDTO perlasCheckIdResponseDTO = perlasService.checkId(perlasCheckIdRequestDTO);

return perlasCheckIdResponseDTO;
}

@PayloadRoot(namespace = SOAP_NAMESPACE, localPart = "saleRequest")
@ResponsePayload
public PerlasSaleResponseDTO createSale(@Valid @RequestPayload PerlasSaleRequestDTO perlasSaleRequestDTO) {
PerlasSaleResponseDTO perlasSaleResponseDTO=perlasService.createSale(perlasSaleRequestDTO);

return perlasSaleResponseDTO;
}
}
@Endpoint
@Validated
public class PerlasEndpoint {
@Autowired
PerlasService perlasService;
private static final String SOAP_NAMESPACE="http://mycompany.lt/soap-web-service";

@PayloadRoot(namespace = SOAP_NAMESPACE,localPart = "idCheckRequest")
@ResponsePayload
public PerlasCheckIdResponseDTO checkId(@Valid @RequestPayload PerlasCheckIdRequestDTO perlasCheckIdRequestDTO) {
Optional<PerlasCheckIdResponseDTO> validationResult=perlasService.validateCheckIdRequest(perlasCheckIdRequestDTO, "CHECK ID");

if (validationResult.isPresent()) {
return validationResult.get();
}

PerlasCheckIdResponseDTO perlasCheckIdResponseDTO = perlasService.checkId(perlasCheckIdRequestDTO);

return perlasCheckIdResponseDTO;
}

@PayloadRoot(namespace = SOAP_NAMESPACE, localPart = "saleRequest")
@ResponsePayload
public PerlasSaleResponseDTO createSale(@Valid @RequestPayload PerlasSaleRequestDTO perlasSaleRequestDTO) {
PerlasSaleResponseDTO perlasSaleResponseDTO=perlasService.createSale(perlasSaleRequestDTO);

return perlasSaleResponseDTO;
}
}
and idk what to do in this situation. can smb help me out? thx
6 Replies
JavaBot
JavaBot3mo ago
This post has been reserved for your question.
Hey @bambyzas! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
tjoener
tjoener3mo ago
throw a custom exception and handle it with a controller advice Told you this one before
bambyzas
bambyzasOP3mo ago
1. can i use controller advice for SOAP? 2. i already have controller advice for my REST service. can i have two controller advices?
tjoener
tjoener3mo ago
Yes you can specify which one to use in your controller itself
bambyzas
bambyzasOP3mo ago
i dont have controller
JavaBot
JavaBot3mo ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
Want results from more Discord servers?
Add your server