-
Notifications
You must be signed in to change notification settings - Fork 317
Description
Luke Hamaty opened SWS-32 and commented
org.springframework.ws.soap.saaj.SaajSoapMessage#getVersion() inpects the Content-Type header to determine the SOAP version, but it is using a simple String equals that does not recognize parameters on the content type. (See http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.7). As a result, getVersion throws an exception if the Content-Type includes an encoding e.g.:
Content-Type: text/xml;charset=UTF-8
My corrected version of the function:
public SoapVersion getVersion() {
String[] contentTypes = saajMessage.getSOAPPart().getMimeHeader(CONTENT_TYPE_HEADER);
if (ObjectUtils.isEmpty(contentTypes)) {
throw new SaajSoapMessageException("Could not read '" + CONTENT_TYPE_HEADER + "' header from message");
}
// Ignore parameters in content type (see http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.7)
int i = contentTypes[0].indexOf(';');
if (i >= 0) {
contentTypes[0] = contentTypes[0].substring(0, i);
}
if (SoapVersion.SOAP_11.getContentType().equals(contentTypes[0])) {
return SoapVersion.SOAP_11;
}
else if (SoapVersion.SOAP_12.getContentType().equals(contentTypes[0])) {
return SoapVersion.SOAP_12;
}
else {
throw new SaajSoapMessageException("Unknown content type [" + contentTypes[0] + "]");
}
}
Affects: 1.0 M1
Issue Links:
- Upgrade to SAAJ 1.3 [SWS-27] #187 Upgrade to SAAJ 1.3
("is depended on by")