How to unmarshall a SOAP Message response XML using JAXB

Solution Unverified - Updated -

Issue

How to unmarshall a SOAP Message response XML using JAXB?

import javax.xml.bind.annotation.*;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "echoResponse", propOrder = {
    "_return"
})
public class EchoResponse {
    @XmlElement(name = "return")
    protected String _return;

    public String getReturn() {
        return _return;
    }
    public void setReturn(String value) {
        this._return = value;
    }
}
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>
        <ns2:echoResponse xmlns:ns2="http://org.jboss.ws/jaxws/test">
            <return>Hello</return>
        </ns2:echoResponse>
    </soap:Body>
</soap:Envelope>

Environment

  • SOAP with Attachments API for Java (SAAJ)
  • Java Architecture for XML Binding (JAXB)

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content