I'm setting up an @Endpoint to handle the following Soap message:
<Envelope xmlns:A="namespaceA" xmlns:B="namespaceB">
<SOAP:Header/>
<Body>
<A:PayloadOne/>
<B:PayloadTwo/>
</Body>
</Envelope>
My method inside the @Endpoint class looks like the following. This works successfully but then I don't have the ability to access the PayloadTwo object.
@PayloadRoot(localPart = "PayloadOne", uri = "namespaceA")
void receive(@RequestPayload PayloadOne value) {...}
I'd like to setup my method so I can receive as method parameters, both payloads. For example:
@PayloadRoots({
@PayloadRoot(localPart = "PayloadOne", uri = "namespaceA"),
@PayloadRoot(localPart = "PayloadTwo", uri = "namespaceB")
})
void receive(@RequestPayload PayloadOne value1, @RequestPayload PayloadTwo value2) {...}
Is that possible?
Have not worked with Spring Boot @Endpoint
in a while, but unless anything has changed recently, what you want is not possible. However, as a workaround, you can modify your SOAP message to add a wrapper:
<Envelope xmlns:A="namespaceA" xmlns:B="namespaceB">
<SOAP:Header/>
<Body>
<A:PayloadWrapper>
<A:PayloadOne/>
<B:PayloadTwo/>
</A:PayloadWrapper>
</Body>
</Envelope>
Create a class that wraps PayloadOne
and PayloadTwo
:
public class PayloadWrapper {
private PayloadOne payloadOne;
private PayloadTwo payloadTwo;
// Public getters/setters.
}
Then change your method:
@PayloadRoot(localPart = "PayloadWrapper", uri = "namespaceA")
public void receive(@RequestPayload PayloadWrapper payloadWrapper) {
PayloadOne payloadOne = payloadWrapper.getPayloadOne();
PayloadTwo payloadTwo = payloadWrapper.getPayloadTwo();
...
}