Skip to content

Commit f59591c

Browse files
committed
SWS-469: Content type not set accouring to Http specification, RFC 2616
1 parent 2f5e7ea commit f59591c

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapMessage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ public void writeTo(OutputStream outputStream) throws IOException {
221221
TransportOutputStream transportOutputStream = (TransportOutputStream) outputStream;
222222
String contentType = format.getContentType();
223223
if (!hasAttachments) {
224-
contentType += "; charset=\"" + charsetEncoding + "\"";
224+
contentType += "; charset=" + charsetEncoding;
225225
}
226226
if (SoapVersion.SOAP_11 == getVersion()) {
227227
transportOutputStream.addHeader(TransportConstants.HEADER_SOAP_ACTION, soapAction);

core/src/test/java/org/springframework/ws/soap/AbstractSoapMessageTestCase.java

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,21 @@
1616

1717
package org.springframework.ws.soap;
1818

19+
import java.io.ByteArrayOutputStream;
20+
import java.util.Map;
21+
import java.util.regex.Matcher;
22+
import java.util.regex.Pattern;
23+
24+
import org.xml.sax.SAXParseException;
25+
1926
import org.springframework.core.io.Resource;
2027
import org.springframework.util.StringUtils;
2128
import org.springframework.ws.mime.AbstractMimeMessageTestCase;
2229
import org.springframework.ws.mime.MimeMessage;
30+
import org.springframework.ws.transport.MockTransportOutputStream;
31+
import org.springframework.ws.transport.TransportConstants;
2332
import org.springframework.xml.validation.XmlValidator;
2433
import org.springframework.xml.validation.XmlValidatorFactory;
25-
import org.xml.sax.SAXParseException;
2634

2735
public abstract class AbstractSoapMessageTestCase extends AbstractMimeMessageTestCase {
2836

@@ -50,6 +58,21 @@ public void testSoapAction() throws Exception {
5058
assertEquals("Invalid SOAP Action", "\"SoapAction\"", soapMessage.getSoapAction());
5159
}
5260

61+
public void testCharsetAttribute() throws Exception {
62+
MockTransportOutputStream outputStream = new MockTransportOutputStream(new ByteArrayOutputStream());
63+
soapMessage.writeTo(outputStream);
64+
Map headers = outputStream.getHeaders();
65+
String contentType = (String) headers.get(TransportConstants.HEADER_CONTENT_TYPE);
66+
if (contentType != null) {
67+
Pattern charsetPattern = Pattern.compile("charset\\s*=\\s*([^;]+)");
68+
Matcher matcher = charsetPattern.matcher(contentType);
69+
if (matcher.find() && matcher.groupCount() == 1) {
70+
String charset = matcher.group(1).trim();
71+
assertTrue("Invalid charset", charset.indexOf('"') < 0);
72+
}
73+
}
74+
}
75+
5376
protected abstract Resource[] getSoapSchemas();
5477

5578
public abstract void testGetVersion() throws Exception;

0 commit comments

Comments
 (0)