Skip to content

Commit 4b765c4

Browse files
committed
SWS-385
1 parent a7793ec commit 4b765c4

File tree

5 files changed

+95
-22
lines changed

5 files changed

+95
-22
lines changed

core-tiger/src/main/java/org/springframework/ws/soap/addressing/server/AnnotationActionEndpointMapping.java

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -96,34 +96,45 @@ protected URI getEndpointAddress(Object endpoint) {
9696
Class endpointClass = methodEndpoint.getMethod().getDeclaringClass();
9797
Address address = AnnotationUtils.findAnnotation(endpointClass, Address.class);
9898
if (address != null && StringUtils.hasText(address.value())) {
99-
try {
100-
return new URI(address.value());
101-
}
102-
catch (URISyntaxException e) {
103-
throw new IllegalArgumentException(
104-
"Invalid Address annotation [" + address.value() + "] on [" + endpointClass + "]");
105-
}
99+
return getActionUri(address.value(), methodEndpoint);
100+
}
101+
else {
102+
return null;
106103
}
107-
return null;
108104
}
109105

110106
protected URI getResponseAction(Object endpoint, MessageAddressingProperties map) {
111107
MethodEndpoint methodEndpoint = (MethodEndpoint) endpoint;
112108
Action action = methodEndpoint.getMethod().getAnnotation(Action.class);
113109
if (action != null && StringUtils.hasText(action.output())) {
114-
try {
115-
return new URI(action.output());
116-
}
117-
catch (URISyntaxException e) {
118-
throw new IllegalArgumentException(
119-
"Invalid Action annotation [" + action.value() + "] on [" + methodEndpoint + "]");
120-
}
110+
return getActionUri(action.output(), methodEndpoint);
121111
}
122112
else {
123113
return super.getResponseAction(endpoint, map);
124114
}
125115
}
126116

117+
protected URI getFaultAction(Object endpoint, MessageAddressingProperties map) {
118+
MethodEndpoint methodEndpoint = (MethodEndpoint) endpoint;
119+
Action action = methodEndpoint.getMethod().getAnnotation(Action.class);
120+
if (action != null && StringUtils.hasText(action.fault())) {
121+
return getActionUri(action.fault(), methodEndpoint);
122+
}
123+
else {
124+
return super.getResponseAction(endpoint, map);
125+
}
126+
}
127+
128+
private URI getActionUri(String action, MethodEndpoint methodEndpoint) {
129+
try {
130+
return new URI(action);
131+
}
132+
catch (URISyntaxException e) {
133+
throw new IllegalArgumentException(
134+
"Invalid Action annotation [" + action + "] on [" + methodEndpoint + "]");
135+
}
136+
}
137+
127138
public final Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
128139
return bean;
129140
}

core-tiger/src/main/java/org/springframework/ws/soap/addressing/server/annotation/Action.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,10 @@
4040
/** Signifies the value for the response WS-Addressing <code>Action</code> header that is provided by the method. */
4141
String output() default "";
4242

43+
/**
44+
* Signifies the value for the fault response WS-Addressing <code>Action</code> header that is provided by the
45+
* method.
46+
*/
47+
String fault() default "";
48+
4349
}

core/src/main/java/org/springframework/ws/soap/addressing/server/AbstractActionEndpointMapping.java

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,34 +31,60 @@
3131
* implementations. Provides infrastructure for mapping endpoints to actions.
3232
* <p/>
3333
* By default, this mapping creates a <code>Action</code> for reply messages based on the request message, plus the
34-
* extra {@link #setOutputActionSuffix(String) suffix}.
34+
* extra {@link #setOutputActionSuffix(String) suffix}, and a * By default, this mapping creates a <code>Action</code>
35+
* for reply messages based on the request message, plus the extra {@link #setOutputActionSuffix(String) suffix}.
3536
*
3637
* @author Arjen Poutsma
3738
* @since 1.5.0
3839
*/
3940
public abstract class AbstractActionEndpointMapping extends AbstractAddressingEndpointMapping
4041
implements ApplicationContextAware {
4142

42-
/** The defaults suffix to add to request <code>Action</code> for reply messages. */
43+
/** The defaults suffix to add to the request <code>Action</code> for reply messages. */
4344
public static final String DEFAULT_OUTPUT_ACTION_SUFFIX = "Response";
4445

46+
/** The defaults suffix to add to response <code>Action</code> for reply messages. */
47+
public static final String DEFAULT_FAULT_ACTION_SUFFIX = "Fault";
48+
4549
// keys are action URIs, values are endpoints
4650
private final Map endpointMap = new HashMap();
4751

4852
private String outputActionSuffix = DEFAULT_OUTPUT_ACTION_SUFFIX;
4953

54+
private String faultActionSuffix = DEFAULT_OUTPUT_ACTION_SUFFIX;
55+
5056
private ApplicationContext applicationContext;
5157

58+
/** Returns the suffix to add to request <code>Action</code>s for reply messages. */
59+
public String getOutputActionSuffix() {
60+
return outputActionSuffix;
61+
}
62+
5263
/**
5364
* Sets the suffix to add to request <code>Action</code>s for reply messages.
5465
*
5566
* @see #DEFAULT_OUTPUT_ACTION_SUFFIX
5667
*/
5768
public void setOutputActionSuffix(String outputActionSuffix) {
58-
Assert.hasText(outputActionSuffix, "'replyActionSuffix' must not be empty");
69+
Assert.hasText(outputActionSuffix, "'outputActionSuffix' must not be empty");
5970
this.outputActionSuffix = outputActionSuffix;
6071
}
6172

73+
/** Returns the suffix to add to request <code>Action</code>s for reply fault messages. */
74+
public String getFaultActionSuffix() {
75+
return faultActionSuffix;
76+
}
77+
78+
/**
79+
* Sets the suffix to add to request <code>Action</code>s for reply fault messages.
80+
*
81+
* @see #DEFAULT_FAULT_ACTION_SUFFIX
82+
*/
83+
public void setFaultActionSuffix(String faultActionSuffix) {
84+
Assert.hasText(faultActionSuffix, "'faultActionSuffix' must not be empty");
85+
this.faultActionSuffix = faultActionSuffix;
86+
}
87+
6288
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
6389
this.applicationContext = applicationContext;
6490
}
@@ -137,10 +163,21 @@ protected void registerEndpoint(URI action, Object endpoint) throws BeansExcepti
137163
protected URI getResponseAction(Object endpoint, MessageAddressingProperties requestMap) {
138164
URI requestAction = requestMap.getAction();
139165
if (requestAction != null) {
140-
return URI.create(requestAction.toString() + outputActionSuffix);
166+
return URI.create(requestAction.toString() + getOutputActionSuffix());
167+
}
168+
else {
169+
return null;
170+
}
171+
}
172+
173+
protected URI getFaultAction(Object endpoint, MessageAddressingProperties requestMap) {
174+
URI requestAction = requestMap.getAction();
175+
if (requestAction != null) {
176+
return URI.create(requestAction.toString() + getFaultActionSuffix());
141177
}
142178
else {
143179
return null;
144180
}
145181
}
182+
146183
}

core/src/main/java/org/springframework/ws/soap/addressing/server/AbstractAddressingEndpointMapping.java

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,12 @@ private EndpointInvocationChain getEndpointInvocationChain(Object endpoint,
198198
AddressingVersion version,
199199
MessageAddressingProperties requestMap) {
200200
URI responseAction = getResponseAction(endpoint, requestMap);
201+
URI faultAction = getFaultAction(endpoint, requestMap);
201202
EndpointInterceptor[] interceptors =
202203
new EndpointInterceptor[preInterceptors.length + postInterceptors.length + 1];
203204
System.arraycopy(preInterceptors, 0, interceptors, 0, preInterceptors.length);
204-
AddressingEndpointInterceptor interceptor =
205-
new AddressingEndpointInterceptor(version, messageIdStrategy, messageSenders, responseAction, null);
205+
AddressingEndpointInterceptor interceptor = new AddressingEndpointInterceptor(version, messageIdStrategy,
206+
messageSenders, responseAction, faultAction);
206207
interceptors[preInterceptors.length] = interceptor;
207208
System.arraycopy(postInterceptors, 0, interceptors, preInterceptors.length + 1, postInterceptors.length);
208209
return new SoapEndpointInvocationChain(endpoint, interceptors, actorsOrRoles, isUltimateReceiver);
@@ -230,6 +231,24 @@ private boolean supports(AddressingVersion version, SoapMessage request) {
230231
*/
231232
protected abstract Object getEndpointInternal(MessageAddressingProperties map);
232233

234+
/**
235+
* Provides the WS-Addressing Action for response messages, given the endpoint, and request Message Addressing
236+
* Properties.
237+
*
238+
* @param endpoint the mapped endpoint
239+
* @param requestMap the MAP for the request
240+
* @return the response Action
241+
*/
233242
protected abstract URI getResponseAction(Object endpoint, MessageAddressingProperties requestMap);
234243

244+
/**
245+
* Provides the WS-Addressing Action for response fault messages, given the endpoint, and request Message Addressing
246+
* Properties.
247+
*
248+
* @param endpoint the mapped endpoint
249+
* @param requestMap the MAP for the request
250+
* @return the response Action
251+
*/
252+
protected abstract URI getFaultAction(Object endpoint, MessageAddressingProperties requestMap);
253+
235254
}

core/src/main/java/org/springframework/ws/soap/addressing/server/AddressingEndpointInterceptor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ private boolean handleResponseOrFault(MessageContext messageContext, boolean isF
104104
}
105105
SoapMessage reply = (SoapMessage) messageContext.getResponse();
106106
URI replyMessageId = getMessageId(reply);
107-
URI action = !isFault ? replyAction : faultAction;
107+
URI action = isFault ? faultAction : replyAction;
108108
MessageAddressingProperties replyMap = requestMap.getReplyProperties(replyEpr, action, replyMessageId);
109109
version.addAddressingHeaders(reply, replyMap);
110110
if (handleAnonymousAddress(messageContext, replyEpr)) {

0 commit comments

Comments
 (0)