Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Ultimately there are two problems that need to be solved:</p> <ol> <li>Inject both the JAXB and Castor marshaller/unmarshaller</li> <li>Determine when when to use JAXB or Castor</li> </ol> <p><strong>Item #1 - Inject both the JAXB and Castor marshaller/unmarshaller</strong></p> <p><em>org.springframework.ws.server.endpoint.adapter.GenericMarshallingMethodEndpointAdapter</em> only has one marshaller property and one unmarshaller property. There may be two ways to solve this problem:</p> <p><em><strong>Option #1 - Subclass GenericMarshallingMethodEndpointAdapter</em></strong></p> <p>You could subclass rg.springframework.ws.server.endpoint.adapter.GenericMarshallingMethodEndpointAdapter and introduce a second marshaller an unmarshaller property. Then you will configure this something like:</p> <pre><code>&lt;bean id="jaxbMarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller"&gt; &lt;property name="contextPath" value="com.example"/&gt; &lt;/bean&gt; &lt;bean id="castorMarshaller" class="org.springframework.oxm.castor.CastorMarshaller"&gt; &lt;property name="mappingLocation"&gt; &lt;value&gt;classpath:config/service/mapping.xml&lt;/value&gt; &lt;/property&gt; &lt;/bean&gt; &lt;bean class="your.domain.YourGenericMarshallingMethodEndpointAdapter"&gt; &lt;property name="marshaller" ref="jaxbMarshaller" /&gt; &lt;property name="unmarshaller" ref="jaxbMarshaller" /&gt; &lt;property name="castorMarshaller" ref="castorMarshaller" /&gt; &lt;property name="castorMarshaller" ref="castorMarshaller" /&gt; &lt;/bean&gt; </code></pre> <p><em><strong>Option #2 - Implement Your own Marshaller</em></strong></p> <p>You could implement your own marshaller that is both JAXB and Castor aware. Then configure it something like:</p> <pre><code>&lt;bean id="marshaller" class="your.domain.CustomMarshaller"&gt; &lt;property name="contextPath" value="com.example"/&gt; &lt;property name="mappingLocation"&gt; &lt;value&gt;classpath:config/service/mapping.xml&lt;/value&gt; &lt;/property&gt; &lt;/bean&gt; &lt;bean class="org.springframework.ws.server.endpoint.adapter.GenericMarshallingMethodEndpointAdapter"&gt; &lt;property name="marshaller" ref="marshaller" /&gt; &lt;property name="unmarshaller" ref="marshaller" /&gt; &lt;/bean&gt; </code></pre> <p><strong>Item #2 - Determine when when to use JAXB or Castor</strong></p> <p>This may be the harder item to solve. Once you have made your endpoint aware of both JAXB and Castor you will still need to choose one to perform the marshal operation. This aspect may be easier to solve with the custom marshaller approach described above.</p> <p><strong>For More Information</strong></p> <p>Here are instructions for configuring JAXB with Spring:</p> <ul> <li><a href="http://wiki.eclipse.org/EclipseLink/Examples/MOXy/Spring/JAXBAnnotations" rel="nofollow">http://wiki.eclipse.org/EclipseLink/Examples/MOXy/Spring/JAXBAnnotations</a></li> </ul> <p>The following contains instructions for configuring Castor (and JAXB):</p> <ul> <li><a href="http://static.springsource.org/spring-ws/sites/1.5/reference/html/oxm.html" rel="nofollow">http://static.springsource.org/spring-ws/sites/1.5/reference/html/oxm.html</a></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload