1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.springframework.ws.soap.server.endpoint.mapping;
18
19 import org.springframework.util.Assert;
20 import org.springframework.util.StringUtils;
21 import org.springframework.ws.context.MessageContext;
22 import org.springframework.ws.server.EndpointInterceptor;
23 import org.springframework.ws.server.EndpointInvocationChain;
24 import org.springframework.ws.server.endpoint.mapping.AbstractMapBasedEndpointMapping;
25 import org.springframework.ws.soap.SoapMessage;
26 import org.springframework.ws.soap.axiom.AxiomSoapMessageFactory;
27 import org.springframework.ws.soap.server.SoapEndpointInvocationChain;
28 import org.springframework.ws.soap.server.SoapEndpointMapping;
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53 public class SoapActionEndpointMapping extends AbstractMapBasedEndpointMapping implements SoapEndpointMapping {
54
55 private String[] actorsOrRoles;
56
57 private boolean isUltimateReceiver = true;
58
59 public final void setActorOrRole(String actorOrRole) {
60 Assert.notNull(actorOrRole, "actorOrRole must not be null");
61 actorsOrRoles = new String[]{actorOrRole};
62 }
63
64 public final void setActorsOrRoles(String[] actorsOrRoles) {
65 Assert.notEmpty(actorsOrRoles, "actorsOrRoles must not be empty");
66 this.actorsOrRoles = actorsOrRoles;
67 }
68
69 public final void setUltimateReceiver(boolean ultimateReceiver) {
70 isUltimateReceiver = ultimateReceiver;
71 }
72
73
74
75
76
77
78
79
80
81
82
83 protected final EndpointInvocationChain createEndpointInvocationChain(MessageContext messageContext,
84 Object endpoint,
85 EndpointInterceptor[] interceptors) {
86 return new SoapEndpointInvocationChain(endpoint, interceptors, actorsOrRoles, isUltimateReceiver);
87 }
88
89 protected String getLookupKeyForMessage(MessageContext messageContext) throws Exception {
90 if (messageContext.getRequest() instanceof SoapMessage) {
91 SoapMessage request = (SoapMessage) messageContext.getRequest();
92 String soapAction = request.getSoapAction();
93 if (StringUtils.hasLength(soapAction) && soapAction.charAt(0) == '"' &&
94 soapAction.charAt(soapAction.length() - 1) == '"') {
95 return soapAction.substring(1, soapAction.length() - 1);
96 }
97 else {
98 return soapAction;
99 }
100 }
101 else {
102 return null;
103 }
104 }
105
106 protected boolean validateLookupKey(String key) {
107 return StringUtils.hasLength(key);
108 }
109 }