Results 1 to 3 of 3

Thread: How to create a SOAP response with Spring WS (without XSD)?

  1. #1
    Join Date
    Nov 2010
    Location
    Utrecht, Netherlands
    Posts
    7

    Default How to create a SOAP response with Spring WS (without XSD)?

    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
    Code:
    @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";
    	}
    }
    Spring-ws-servlet.xml
    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!

  2. #2
    Join Date
    Nov 2010
    Location
    Utrecht, Netherlands
    Posts
    7

    Default

    Solution for now: I've written an extra XSD, but still I'm very curious of how to create a response manually (using Spring WS).
    If I take a look at the response classes (created by JAXB) I notice that various annotations are being used to define the class as a SOAP Response object for Spring WS. I'd love to get more info about this, but I can't find any good documentation (what do those annotations mean, which annotations are available, how to use them in Spring WS, what do I have to configure, etc). So if any of you know a good article, tutorial or plain documentation (not the API), I'm all ears!

  3. #3

    Default

    Recently I read a pretty interesting tutorial on how to find a link that will share
    Last edited by wikes; Mar 26th, 2012 at 06:18 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •