SOAP/XML
Juneau supports serializing POJOs to SOAP-wrapped XML using the SoapXmlSerializer class.
The output is essentially the same as the standard Juneau XML serializer, wrapped in a standard SOAP envelope.
Since SoapXmlSerializer extends the XML serializer, all XML serializer builder settings and annotations apply.
SOAP/XML support is included in juneau-marshall.
| Maven | |
|---|
The relevant classes are:
This is a serialize-only language — there is no corresponding SOAP parser.
Media Types
The serializer handles the Accept type text/xml+soap and produces Content-Type: text/xml.
A SOAPAction HTTP response header is set from the configured SOAP action value.
Sample Code
// Create a SOAP/XML serializer.
SoapXmlSerializer serializer = SoapXmlSerializer.create().build();
// Serialize a POJO.
String soapXml = serializer.write(myPojo);
The POJO is serialized using the standard Juneau XML rules and wrapped in a SOAP envelope:
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
<soap:Body>
<!-- Standard Juneau XML output for the POJO. -->
</soap:Body>
</soap:Envelope>
See XML Support for details on how POJOs are mapped to the XML placed inside the SOAP body.
Configuration
The SOAP action value is used both as the soap namespace URI written into the envelope and as the value of the
SOAPAction HTTP response header. It defaults to http://www.w3.org/2003/05/soap-envelope and can be overridden via
the builder:
SoapXmlSerializer serializer = SoapXmlSerializer
.create()
.soapAction("http://example.com/MyService/MyAction")
.build();
The same setting can be applied declaratively on REST classes and methods using @SoapXmlConfig(soapAction="...").
- XML Support for the underlying XML serialization rules.
- Serializers and Parsers for the common serializer builder API.