1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.springframework.ws.server.endpoint.adapter.method;
18
19 import javax.xml.transform.Source;
20
21 import org.springframework.core.MethodParameter;
22 import org.springframework.ws.WebServiceMessage;
23 import org.springframework.ws.context.MessageContext;
24 import org.springframework.ws.server.endpoint.annotation.RequestPayload;
25
26
27
28
29
30
31
32
33 public abstract class AbstractPayloadSourceMethodProcessor extends AbstractPayloadMethodProcessor {
34
35
36
37 public final Object resolveArgument(MessageContext messageContext, MethodParameter parameter) throws Exception {
38 Source requestPayload = getRequestPayload(messageContext);
39 return requestPayload != null ? resolveRequestPayloadArgument(parameter, requestPayload) : null;
40 }
41
42
43 private Source getRequestPayload(MessageContext messageContext) {
44 WebServiceMessage request = messageContext.getRequest();
45 return request != null ? request.getPayloadSource() : null;
46 }
47
48
49
50
51
52
53
54
55
56 protected abstract Object resolveRequestPayloadArgument(MethodParameter parameter, Source requestPayload)
57 throws Exception;
58
59
60
61 public final void handleReturnValue(MessageContext messageContext, MethodParameter returnType, Object returnValue)
62 throws Exception {
63 if (returnValue != null) {
64 Source responsePayload = createResponsePayload(returnType, returnValue);
65 if (responsePayload != null) {
66 WebServiceMessage response = messageContext.getResponse();
67 transform(responsePayload, response.getPayloadResult());
68 }
69 }
70 }
71
72
73
74
75
76
77
78
79
80 protected abstract Source createResponsePayload(MethodParameter returnType, Object returnValue) throws Exception;
81
82 }