Uploaded image for project: 'Spring Web Services'
  1. Spring Web Services
  2. SWS-32

SaajSoapMessage does not work if content type includes parameters

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.0 M1
    • Fix Version/s: 1.0 M2
    • Component/s: Core
    • Labels:
      None

      Description

      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] + "]"); }

      }

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                arjen.poutsma Arjen Poutsma
                Reporter:
                wlhamaty Luke Hamaty
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: