In questo articolo vedremo le tecniche di marshalling che mette a disposizione Spring-ws per la gestione dei messaggi di richiesta e risposta dei web services.
Tutte le implementazione degli endpoint fornite dal framework prevedono 2 proprietà:
<bean id="jaxb2Marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller"><property name="contextPath" value="it.finazzo.libreria.schema"/><property name="schema" value="classpath:schema.xsd"/></bean><bean id="ricercaLibroEndpoint" class="it.finazzo.libreria.ws.RicercaLibroEndpoint"><property name="marshaller" ref="jaxb2Marshaller"></property><property name="unmarshaller" ref="jaxb2Marshaller"></property></bean>
<plugin><groupId>com.sun.tools.xjc.maven2</groupId><artifactId>maven-jaxb-plugin</artifactId><executions><execution><phase>generate-sources</phase><goals><goal>generate</goal></goals></execution></executions><configuration><generatePackage>it.finazzo.libreria.schema</generatePackage></configuration></plugin>e definire le resources
<resource> <directory>src/main/resources</directory> <filtering>true</filtering></resource>
public class RicercaLibroEndpoint extends AbstractMarshallingPayloadEndpoint {protected Object invokeInternal(Object arg0) throws Exception {return new RicercaLibroResponse();}}