TheJaxb2Marshaller
class implements both the SpringMarshaller
andUnmarshaller
interface. It requires a context path to operate, which you can set using thecontextPath
property. The context path is a list of colon (:) separated Java package names that contain schema derived classes. It also offers aclassesToBeBound
property, which allows you to set an array of classes to be supported by the marshaller. Schema validation is performed by specifying one or more schema resource to the bean, like so:
<beans>
<bean id="jaxb2Marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<property name="classesToBeBound">
<list>
<value>org.springframework.oxm.jaxb.Flight</value>
<value>org.springframework.oxm.jaxb.Flights</value>
</list>
</property>
<property name="schema" value="classpath:org/springframework/oxm/schema.xsd"/>
</bean>
...
</beans>
Thejaxb2-marshaller
tag configures aorg.springframework.oxm.jaxb.Jaxb2Marshaller
. Here is an example:
<oxm:jaxb2-marshaller id="marshaller" contextPath="org.springframework.ws.samples.airline.schema"/>
Alternatively, the list of classes to bind can be provided to the marshaller via theclass-to-be-bound
child tag:
<oxm:jaxb2-marshaller id="marshaller">
<oxm:class-to-be-bound name="org.springframework.ws.samples.airline.schema.Airport"/>
<oxm:class-to-be-bound name="org.springframework.ws.samples.airline.schema.Flight"/>
...
</oxm:jaxb2-marshaller>
Available attributes are:
Attribute | Description | Required |
---|---|---|
id |
the id of the marshaller | no |
contextPath |
the JAXB Context path | no |