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

JDOM exception when parsing odd SOAP message with SaajSoapMessageFactor

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Won't Fix
    • Affects Version/s: 1.5.6
    • Fix Version/s: 1.5.7
    • Component/s: None
    • Labels:
      None

      Description

      I'm trying to accept a SOAP message that has the following format:

      <?xml version="1.0" encoding="UTF-8"?>
      <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
          <SOAP-ENV:Body>
              <ns0:programStatusRequest version="1.0"
                  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
                  xmlns:ns0="http://mynamespace">
                  <ns0:programName
                      xmlns:ns0="http://mynamespace">Residential LCR Cooling 50% Contract</ns0:programName>
              </ns0:programStatusRequest>
          </SOAP-ENV:Body>
      </SOAP-ENV:Envelope>  

      The strange part of this message is that the xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" is redefined on the payload element (I'm not sure, I assume it is auto generated this way).

      I am not able to accept this message using the org.springframework.ws.soap.saaj.SaajSoapMessageFactory. However, using org.springframework.ws.soap.axiom.AxiomSoapMessageFactory allows this message to be parsed successfully.

      To better demostrate this, I've created the following:

      String messageFactoryProtocol = SOAPConstants.SOAP_1_1_PROTOCOL;
      MessageFactory messageFactory = MessageFactory.newInstance(messageFactoryProtocol);
      MimeHeaders mimeHeaders = new MimeHeaders();
      SOAPMessage message = messageFactory.createMessage(mimeHeaders, file.toURI().toURL().openStream()); // where file contains the above XML
      SaajSoapMessage saajSoapMessage = new SaajSoapMessage(message);
      result = new JDOMResult();
      // result = new StringResult(); // using the Spring StringResult works just fine
      newTransformer.transform(saajSoapMessage.getPayloadSource(), result); // this line throws the exception

      Running this code produces:

      org.jdom.IllegalNameException: The name "" is not legal for JDOM/XML namespaces: Namespace URIs must be non-null and non-empty Strings.
      	at org.jdom.Namespace.getNamespace(Namespace.java:166)
      	at org.jdom.input.SAXHandler.startPrefixMapping(SAXHandler.java:498)
      	at org.xml.sax.helpers.XMLFilterImpl.startPrefixMapping(XMLFilterImpl.java:490)
      	at org.jdom.transform.JDOMResult$DocumentBuilder.startPrefixMapping(JDOMResult.java:529)
      	at com.sun.org.apache.xml.internal.serializer.ToXMLSAXHandler.startPrefixMapping(ToXMLSAXHandler.java:362)
      	at com.sun.org.apache.xml.internal.serializer.ToXMLSAXHandler.namespaceAfterStartElement(ToXMLSAXHandler.java:569)
      	at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(DOM2TO.java:167)
      	at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(DOM2TO.java:90)
      	at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transformIdentity(TransformerImpl.java:662)
      	at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:708)
      	at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:313)

        Issue Links

          Activity

            People

            • Assignee:
              arjen.poutsma Arjen Poutsma
              Reporter:
              tommack Tom Mack
            • Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: