spring-framework / org.springframework.http.converter.xml / MarshallingHttpMessageConverter

MarshallingHttpMessageConverter

open class MarshallingHttpMessageConverter : AbstractXmlHttpMessageConverter<Any>

Implementation of org.springframework.http.converter.HttpMessageConverter that can read and write XML using Spring's Marshaller and Unmarshaller abstractions.

This converter requires a Marshaller and Unmarshaller before it can be used. These can be injected by the constructor or bean properties.

By default, this converter supports text/xml and application/xml. This can be overridden by setting the supportedMediaTypes property.

Author
Arjen Poutsma

Since
3.0

Constructors

<init>

MarshallingHttpMessageConverter()

Construct a new MarshallingHttpMessageConverter with no Marshaller or Unmarshaller set. The Marshaller and Unmarshaller must be set after construction by invoking #setMarshaller(Marshaller) and #setUnmarshaller(Unmarshaller).

MarshallingHttpMessageConverter(marshaller: Marshaller)

Construct a new MarshallingMessageConverter with the given Marshaller set.

If the given Marshaller also implements the Unmarshaller interface, it is used for both marshalling and unmarshalling. Otherwise, an exception is thrown.

Note that all Marshaller implementations in Spring also implement the Unmarshaller interface, so that you can safely use this constructor.

MarshallingHttpMessageConverter(marshaller: Marshaller, unmarshaller: Unmarshaller)

Construct a new MarshallingMessageConverter with the given Marshaller and Unmarshaller.

Functions

canRead

open fun canRead(clazz: Class<*>, mediaType: MediaType): Boolean

canWrite

open fun canWrite(clazz: Class<*>, mediaType: MediaType): Boolean

setMarshaller

open fun setMarshaller(marshaller: Marshaller): Unit

Set the Marshaller to be used by this message converter.

setUnmarshaller

open fun setUnmarshaller(unmarshaller: Unmarshaller): Unit

Set the Unmarshaller to be used by this message converter.