#how to return multiple objects in SOAP webservice?

8 messages · Page 1 of 1 (latest)

alpine sparrow
#

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;
    }
}

and idk what to do in this situation. can smb help me out? thx

sinful abyssBOT
#

This post has been reserved for your question.

Hey @alpine sparrow! 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.

misty tusk
#

throw a custom exception and handle it with a controller advice

#

Told you this one before

alpine sparrow
misty tusk
#

Yes you can specify which one to use in your controller itself

alpine sparrow