Reputation: 1
I have a question on JAXB mapping using org.springframework.ws.server.endpoint.annotations.
I was able to generate Java domain object with provided *.xsd. The thing is after I define my endpoint with @PayloadRoot, I have to wrap my request and response as below to successfully trigger the method and return a result:
@PayloadRoot( localPart = "PmtAuthAddRequest",
namespace = "http://*com/emb/webseries")
@ResponsePayload
public JAXBElement billPayment(@RequestPayload JAXBElement var1){
PmtAuthAddResponseType response=billPaymentHandler.execute(var1.getValue());
return of.createPmtAuthAddResponse(response); // Used ObjectFactory to create JAXBElement.
}`
`
From all the tutorial I see, they dont need to wrap it as JAXBElement to return the correct type, but the below code does not work for me:
`
`@PayloadRoot( localPart = "PmtAuthAddRequest",
namespace = "http://*com/emb/webseries")
@ResponsePayload
public PmtAuthAddResponseType billPayment(@RequestPayload PmtAuthAddRequestType> var1){
PmtAuthAddResponseType response=billPaymentHandler.execute(var1.getValue());
return response;
}`
`
Do you guys know why? How can I resolve this? Thanks
I tried without wrapping it as JAXBElement, but soap UI return with error message:
`no adapter for endpoint [public com.*.*.*.webseries.billpay.CustPayee50InqResponseType com.*.Endpoint.InquirePayeeEndpoint.inquirepayees(com.*.*.*.webseries.billpay.CustPayee50InqRequestType) throws javax.xml.bind.JAXBException]: Is your endpoint annotated with @Endpoint, or does it implement a supported interface like MessageHandler or PayloadEndpoint?</faultstring>
`
Upvotes: 0
Views: 719
Reputation: 1
Actually solved my own question....
The way to do it is to add @XmlRootElement under generated Java class from JAXB2 with below to correctly mapping:
@XmlRootElement(namespace = "http://..*/emb/webseries",name = "CustPayee50InqRequest")
The name should match with the localPart provided name from @PayloadRoot.
Added both for request and response makes it work for me
Upvotes: 0