Skip to content

Commit 9fedbac

Browse files
author
Tareq Abedrabbo
committed
SWS-595 - SoapUtils.setActionInContentType incorrectly replaces existing actions
1 parent 12696a0 commit 9fedbac

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

core/src/main/java/org/springframework/ws/soap/support/SoapUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public static String setActionInContentType(String contentType, String action) {
7979
Matcher matcher = ACTION_PATTERN.matcher(contentType);
8080
if (matcher.find() && matcher.groupCount() == 1) {
8181
StringBuffer buffer = new StringBuffer();
82-
matcher.appendReplacement(buffer, action);
82+
matcher.appendReplacement(buffer, "action=" + action);
8383
matcher.appendTail(buffer);
8484
return buffer.toString();
8585
}

core/src/test/java/org/springframework/ws/soap/support/SoapUtilsTest.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ public void testExtractActionFromContentType() throws Exception {
3434
contentType = "application/soap+xml; action=" + soapAction + " ; charset=UTF-8";
3535
result = SoapUtils.extractActionFromContentType(contentType);
3636
assertEquals("Invalid SOAP action", soapAction, result);
37+
38+
contentType = "application/soap+xml; charset=UTF-8; action=" + soapAction;
39+
result = SoapUtils.extractActionFromContentType(contentType);
40+
assertEquals("Invalid SOAP action", soapAction, result);
3741
}
3842

3943
public void testEscapeAction() throws Exception {
@@ -51,4 +55,18 @@ public void testEscapeAction() throws Exception {
5155

5256
}
5357

58+
public void testSetActionInContentType() throws Exception {
59+
String soapAction = "http://springframework.org/spring-ws/Action";
60+
String contentType = "application/soap+xml";
61+
62+
String result = SoapUtils.setActionInContentType(contentType, soapAction);
63+
assertEquals("Invalid SOAP action", soapAction, SoapUtils.extractActionFromContentType(result));
64+
65+
String anotherSoapAction = "http://springframework.org/spring-ws/AnotherAction";
66+
String contentTypeWithAction = "application/soap+xml; action=http://springframework.org/spring-ws/Action";
67+
result = SoapUtils.setActionInContentType(contentTypeWithAction, anotherSoapAction);
68+
assertEquals("Invalid SOAP action", anotherSoapAction, SoapUtils.extractActionFromContentType(result));
69+
70+
}
71+
5472
}

0 commit comments

Comments
 (0)