f6ff0221c7e828e8e17d1fb8df375251fe313018
[SpringWebServicesForFun/.git] /
1 package de.spring.webservices.endpoints;
2
3 import org.jdom2.Element;
4 import org.springframework.beans.factory.annotation.Autowired;
5 import org.springframework.ws.context.MessageContext;
6 import org.springframework.ws.server.endpoint.annotation.Endpoint;
7 import org.springframework.ws.server.endpoint.annotation.PayloadRoot;
8 import org.springframework.ws.server.endpoint.annotation.RequestPayload;
9 import org.springframework.ws.server.endpoint.annotation.ResponsePayload;
10
11 import de.spring.webservices.operations.Operations;
12 import de.spring.webservices.operations.Operations.RequestResponse;
13 import de.spring.webservices.server.auto.CustomBindingExampleRequest;
14 import de.spring.webservices.server.auto.CustomBindingExampleResponse;
15 import de.spring.webservices.server.auto.ExampleRequest;
16 import de.spring.webservices.server.auto.ExampleResponse;
17 import de.spring.webservices.services.ExampleService;
18
19
20 @Endpoint
21 public class ExampleEndPoint {
22     private static final String NAMESPACE_URI = "http://gumartinm.name/spring-ws/example";
23     
24     private final Operations.RequestResponse
25         <CustomBindingExampleResponse, CustomBindingExampleRequest> customBindingExampleService;  
26     
27     private final ExampleService exampleService;
28     
29     @Autowired
30         public ExampleEndPoint(
31             RequestResponse<CustomBindingExampleResponse, CustomBindingExampleRequest> customBindingExampleService,
32             ExampleService exampleService) {
33             this.customBindingExampleService = customBindingExampleService;
34             this.exampleService = exampleService;
35     }
36         
37     // WARNING!!! RESPONSE OBJECT MUST BE ANNOTATED WITH @XmlRootElement
38     // (ExampleResponse has such annotation)
39     // OTHERWISE YOU WILL SEE THIS WEIRD ERROR: "No adapter for endPoint"
40     // see: http://stackoverflow.com/a/22227806
41     @PayloadRoot(localPart = "ExampleRequest", namespace = NAMESPACE_URI)
42     @ResponsePayload
43     public ExampleResponse exampleResponse(
44             @RequestPayload final ExampleRequest request,
45             @RequestPayload final Element element,
46             final MessageContext messageContext) {
47
48         return this.exampleService.doResponse(request);
49     }
50     
51     // WARNING!!! RESPONSE OBJECT MUST BE ANNOTATED WITH @XmlRootElement
52     // (CustomBindingExampleResponse has such annotation)
53     // OTHERWISE YOU WILL SEE THIS WEIRD ERROR: "No adapter for endPoint"
54     // see: http://stackoverflow.com/a/22227806
55     @PayloadRoot(localPart = "CustomBindingExampleRequest", namespace = NAMESPACE_URI)
56     @ResponsePayload
57     public CustomBindingExampleResponse cuntomBindingExampleResponse(
58             @RequestPayload final CustomBindingExampleRequest requestObject,
59             @RequestPayload final Element element,
60             final MessageContext messageContext) {
61
62         return this.customBindingExampleService.requestResponse(requestObject);
63     }
64 }
65