Jaxb2Marshaller and primitive types
- by Thomas Einwaller
Is it possible to create a web service operation using primitive or basic Java types when using the Jaxb2Marschaller in spring-ws? For example a method looking like this:
@Override
@PayloadRoot(localPart = "AddTaskRequest", namespace = "http://example.com/examplews/")
public long addTask(final Task task) throws AddTaskFault {
// do something
return 0;
}
I am using the maven jaxws plugin to generate the interface and model classes from my WSDL. When I try to call the webservice I get the following error:
java.lang.IllegalStateException: No adapter for endpoint [...]: Does your endpoint implement a supported interface like MessageHandler or PayloadEndpoint
I found out that if I change the method to that:
@Override
@PayloadRoot(localPart = "AddTaskRequest", namespace = "http://example.com/examplews/")
public JAXBElement<Long> addTask(final JAXBElement<Task> task) throws AddTaskFault {
final ObjectFactory objectFactory = new ObjectFactory();
return objectFactory.createAddTaskResponse(0L);
}
I am able to call it - but this signature is not compatible with the interface generated by the maven jaxws plugin.
What can I do to configure either spring-ws to be able to use the first kind of implementation or to tell maven jaxws plugin to generate the second variant of the interface?
UPDATE: My relevant spring-ws config entries look like that:
<bean id="marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<property name="contextPath" value="com.example.examplews" />
</bean>
<bean class="org.springframework.ws.server.endpoint.adapter.GenericMarshallingMethodEndpointAdapter">
<constructor-arg ref="marshaller" />
</bean>
<bean class="org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping">
<property name="order" value="1" />
</bean>