Good day all,
At the moment I have created a very simple webservice based on Spring WS Annotations. It works thus far in a basic mono-directional way: it can receive a SOAP request and handle it. But now I'd love to add a very simple SOAP response to it. I thought using the @ResponsePayload annotation in the endpoint would do the trick, but guess there is more to it than meets my simple eye.
Code Generation (JAXB)
The webservice holds generated classes based on a single XSD (which does not specify any response types). Generation is done using JAXB and Maven. Normally (with other webservices) I use XSD files that define a request and a response type, resulting in generated source code holding Response objects. I don't have those definitions available now. It should be fairly simple to create a response, I guess. Just don't know how the code should look like.
Below the code I have so far. The endpoint only needs to send a SOAP response with one single simple String value (which of course can vary).
The Endpoint
Spring-ws-servlet.xmlCode:@Endpoint public class BrkMutatieServiceEndpoint { @PayloadRoot(localPart = "CheckinRequest", namespace="http://www.company.com/schemas/v2012") @ResponsePayload public String checkinType() { System.out.println("SOAP Message received"); return "response"; } }
Code:<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:sws="http://www.springframework.org/schema/web-services" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/web-services http://www.springframework.org/schema/web-services/web-services-2.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> <context:component-scan base-package="com.company.test.ws" /> <sws:annotation-driven /> <bean id="brk-ws" class="org.springframework.ws.wsdl.wsdl11.SimpleWsdl11Definition"> <constructor-arg value="WEB-INF/xsd/test-ws.wsdl" /> </bean> </beans>
My guesses are to create an extra XSD (but I'd rather not, as I think it should be easier with Spring WS) or implement a class that creates a SOAP response and that an instance is returned in the endpoint. I just don't know how such response class should look like. If any of you have an example or suitable solution, I'd be a happy man again.
Thanks in advance!


.
Reply With Quote
