From 9fedbace16736ebd3e2fcca6dc1279d55bc5e464 Mon Sep 17 00:00:00 2001 From: Tareq Abedrabbo Date: Wed, 13 Jan 2010 21:42:37 +0000 Subject: [PATCH] SWS-595 - SoapUtils.setActionInContentType incorrectly replaces existing actions --- .../ws/soap/support/SoapUtils.java | 2 +- .../ws/soap/support/SoapUtilsTest.java | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/springframework/ws/soap/support/SoapUtils.java b/core/src/main/java/org/springframework/ws/soap/support/SoapUtils.java index b67bdc41..f6e26e30 100644 --- a/core/src/main/java/org/springframework/ws/soap/support/SoapUtils.java +++ b/core/src/main/java/org/springframework/ws/soap/support/SoapUtils.java @@ -79,7 +79,7 @@ public abstract class SoapUtils { Matcher matcher = ACTION_PATTERN.matcher(contentType); if (matcher.find() && matcher.groupCount() == 1) { StringBuffer buffer = new StringBuffer(); - matcher.appendReplacement(buffer, action); + matcher.appendReplacement(buffer, "action=" + action); matcher.appendTail(buffer); return buffer.toString(); } diff --git a/core/src/test/java/org/springframework/ws/soap/support/SoapUtilsTest.java b/core/src/test/java/org/springframework/ws/soap/support/SoapUtilsTest.java index bb098b4f..87a1bbcf 100644 --- a/core/src/test/java/org/springframework/ws/soap/support/SoapUtilsTest.java +++ b/core/src/test/java/org/springframework/ws/soap/support/SoapUtilsTest.java @@ -34,6 +34,10 @@ public class SoapUtilsTest extends TestCase { contentType = "application/soap+xml; action=" + soapAction + " ; charset=UTF-8"; result = SoapUtils.extractActionFromContentType(contentType); assertEquals("Invalid SOAP action", soapAction, result); + + contentType = "application/soap+xml; charset=UTF-8; action=" + soapAction; + result = SoapUtils.extractActionFromContentType(contentType); + assertEquals("Invalid SOAP action", soapAction, result); } public void testEscapeAction() throws Exception { @@ -51,4 +55,18 @@ public class SoapUtilsTest extends TestCase { } + public void testSetActionInContentType() throws Exception { + String soapAction = "http://springframework.org/spring-ws/Action"; + String contentType = "application/soap+xml"; + + String result = SoapUtils.setActionInContentType(contentType, soapAction); + assertEquals("Invalid SOAP action", soapAction, SoapUtils.extractActionFromContentType(result)); + + String anotherSoapAction = "http://springframework.org/spring-ws/AnotherAction"; + String contentTypeWithAction = "application/soap+xml; action=http://springframework.org/spring-ws/Action"; + result = SoapUtils.setActionInContentType(contentTypeWithAction, anotherSoapAction); + assertEquals("Invalid SOAP action", anotherSoapAction, SoapUtils.extractActionFromContentType(result)); + + } + } \ No newline at end of file