Reputation: 340
I'm getting a SOAP request as string, from which I want to extract a Java object. Is it possible? If yes, then how? What API can be used for this?
Upvotes: 3
Views: 8520
Reputation: 148977
I'm getting a SOAP request as string, from which I want to extract a Java object. Is it possible?
Yes.
If yes, then how?
You need to convert the String
into something that JAXB can unmarshal. Examples include a StringReader
or XMLStreamReader
.
What API can be used for this?
Since a SOAP message contains more information than what corresponds to the domain model I would recommend using JAXB with a StAX XMLStreamReader
. You use StAX
to parser the String
. Then you advance the XMLStreamReader
to the element that contains the content you wish to unmarshal. Then you unmarshal the XMLStreamReader
at that point.
Upvotes: 3