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

          Hide
          arjen.poutsma Arjen Poutsma added a comment -

          Added formatting to make the issue readable.

          Show
          arjen.poutsma Arjen Poutsma added a comment - Added formatting to make the issue readable.
          Hide
          arjen.poutsma Arjen Poutsma added a comment -

          On first glance, this seems to be more a JDOM issue than a Spring-WS issue. Not sure what we can do about it...

          Show
          arjen.poutsma Arjen Poutsma added a comment - On first glance, this seems to be more a JDOM issue than a Spring-WS issue. Not sure what we can do about it...
          Hide
          tommack Tom Mack added a comment -

          I don't believe this is a JDOM issue because it really is called with a "" namespace even though the input document does not contain any namespaces declared as "". The "" is stored in the saajSoapMessage object and doesn't appear to pose any problem until the result transform step.

          Although that isn't to say that it isn't a SAAJ problem--when I was stepping through it, I wasn't able to determine if the problem was in Spring-WS code or SAAJ code.

          Show
          tommack Tom Mack added a comment - I don't believe this is a JDOM issue because it really is called with a "" namespace even though the input document does not contain any namespaces declared as "". The "" is stored in the saajSoapMessage object and doesn't appear to pose any problem until the result transform step. Although that isn't to say that it isn't a SAAJ problem--when I was stepping through it, I wasn't able to determine if the problem was in Spring-WS code or SAAJ code.
          Hide
          tunaranch Haikal Saadh added a comment -

          I think this is a related problem. On a spring web service endpoint, with Saaj and Jaxb, I'm getting faults that return:

          <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
            <env:Header/>
            <env:Body>
            	<env:Fault>
            		<faultcode xmlns="">env:Server</faultcode>
            		<faultstring xmlns="">Message goes here</faultstring>
            		<detail xmlns="">
            			...
            		</detail>
            	</env:Fault>
            </env:Body>
          </env:Envelope>

          Show
          tunaranch Haikal Saadh added a comment - I think this is a related problem. On a spring web service endpoint, with Saaj and Jaxb, I'm getting faults that return: <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"> <env:Header/> <env:Body> <env:Fault> <faultcode xmlns="">env:Server</faultcode> <faultstring xmlns="">Message goes here</faultstring> <detail xmlns=""> ... </detail> </env:Fault> </env:Body> </env:Envelope>
          Hide
          tunaranch Haikal Saadh added a comment -

          Actually, my problem seems to be more like this: http://www.stevideter.com/2009/02/18/of-exceptionresolvers-and-xmlbeans/, except I'm using jaxb.

          I don't seem to have saxon in my classpath, mvn dependency:tree gives me:

          [INFO] +- backport-util-concurrent:backport-util-concurrent:jar:3.1:compile
          [INFO] +- log4j:log4j:jar:1.2.15:compile
          [INFO] +- org.springframework.ws:spring-oxm:jar:1.5.5:compile
          [INFO] |  +- org.springframework.ws:spring-xml:jar:1.5.5:compile
          [INFO] |  +- org.springframework:spring-context:jar:2.5.6:compile
          [INFO] |  |  \- aopalliance:aopalliance:jar:1.0:compile
          [INFO] |  +- commons-logging:commons-logging:jar:1.1.1:compile
          [INFO] |  +- org.springframework:spring-core:jar:2.5.6:compile
          [INFO] |  \- org.springframework:spring-beans:jar:2.5.6:compile
          [INFO] +- org.springframework.ws:spring-ws-core:jar:1.5.5:compile
          [INFO] |  +- org.springframework:spring-aop:jar:2.5.6:compile
          [INFO] |  +- org.springframework:spring-web:jar:2.5.6:compile
          [INFO] |  +- org.springframework:spring-webmvc:jar:2.5.6:compile
          [INFO] |  |  \- org.springframework:spring-context-support:jar:2.5.6:compile
          [INFO] |  \- wsdl4j:wsdl4j:jar:1.6.1:compile
          [INFO] +- stax:stax-api:jar:1.0.1:compile
          [INFO] +- xml-apis:xml-apis:jar:1.3.04:compile
          [INFO] +- org.springframework:spring:jar:2.5.6:compile
          [INFO] +- org.springframework.ws:spring-ws-core-tiger:jar:1.5.5:compile
          [INFO] +- org.springframework.ws:spring-oxm-tiger:jar:1.5.5:compile
          [INFO] +- javax.xml.bind:jaxb-api:jar:2.1:compile
          [INFO] +- com.sun.xml.bind:jaxb-impl:jar:2.1.3:compile
          [INFO] +- com.oracle:ojdbc14:jar:10.2.0.3.0:provided
          [INFO] +- xerces:xercesImpl:jar:2.8.1:compile
          [INFO] +- xalan:xalan:jar:2.7.0:compile
           
          [INFO] |  \- commons-lang:commons-lang:jar:2.3:compile
           
          [INFO] |  \- org.springframework:spring-jdbc:jar:2.5.6:compile
          [INFO] |     \- org.springframework:spring-tx:jar:2.5.6:compile
           
           
          [INFO] +- org.hamcrest:hamcrest-all:jar:1.1:test (scope not updated to compile)
          [INFO] +- org.easymock:easymockclassextension:jar:2.3:test
          [INFO] |  +- org.easymock:easymock:jar:2.3:test
          [INFO] |  \- cglib:cglib-nodep:jar:2.1_3:test
          [INFO] +- xmlunit:xmlunit:jar:1.2:test
          [INFO] +- junit:junit:jar:4.4:test
          [INFO] +- org.apache.ws.commons.schema:XmlSchema:jar:1.4.2:compile
          [INFO] +- org.springframework:spring-test:jar:2.5.6:test
          [INFO] \- au.edu.qut.qutvirtual.unitservice:unitservice-testhelpers:jar:1.2.2-SNAPSHOT:test
          [INFO]    \- org.testng:testng:jar:jdk15:5.8:test

          Show
          tunaranch Haikal Saadh added a comment - Actually, my problem seems to be more like this: http://www.stevideter.com/2009/02/18/of-exceptionresolvers-and-xmlbeans/ , except I'm using jaxb. I don't seem to have saxon in my classpath, mvn dependency:tree gives me: [INFO] +- backport-util-concurrent:backport-util-concurrent:jar:3.1:compile [INFO] +- log4j:log4j:jar:1.2.15:compile [INFO] +- org.springframework.ws:spring-oxm:jar:1.5.5:compile [INFO] | +- org.springframework.ws:spring-xml:jar:1.5.5:compile [INFO] | +- org.springframework:spring-context:jar:2.5.6:compile [INFO] | | \- aopalliance:aopalliance:jar:1.0:compile [INFO] | +- commons-logging:commons-logging:jar:1.1.1:compile [INFO] | +- org.springframework:spring-core:jar:2.5.6:compile [INFO] | \- org.springframework:spring-beans:jar:2.5.6:compile [INFO] +- org.springframework.ws:spring-ws-core:jar:1.5.5:compile [INFO] | +- org.springframework:spring-aop:jar:2.5.6:compile [INFO] | +- org.springframework:spring-web:jar:2.5.6:compile [INFO] | +- org.springframework:spring-webmvc:jar:2.5.6:compile [INFO] | | \- org.springframework:spring-context-support:jar:2.5.6:compile [INFO] | \- wsdl4j:wsdl4j:jar:1.6.1:compile [INFO] +- stax:stax-api:jar:1.0.1:compile [INFO] +- xml-apis:xml-apis:jar:1.3.04:compile [INFO] +- org.springframework:spring:jar:2.5.6:compile [INFO] +- org.springframework.ws:spring-ws-core-tiger:jar:1.5.5:compile [INFO] +- org.springframework.ws:spring-oxm-tiger:jar:1.5.5:compile [INFO] +- javax.xml.bind:jaxb-api:jar:2.1:compile [INFO] +- com.sun.xml.bind:jaxb-impl:jar:2.1.3:compile [INFO] +- com.oracle:ojdbc14:jar:10.2.0.3.0:provided [INFO] +- xerces:xercesImpl:jar:2.8.1:compile [INFO] +- xalan:xalan:jar:2.7.0:compile   [INFO] | \- commons-lang:commons-lang:jar:2.3:compile   [INFO] | \- org.springframework:spring-jdbc:jar:2.5.6:compile [INFO] | \- org.springframework:spring-tx:jar:2.5.6:compile     [INFO] +- org.hamcrest:hamcrest-all:jar:1.1:test (scope not updated to compile) [INFO] +- org.easymock:easymockclassextension:jar:2.3:test [INFO] | +- org.easymock:easymock:jar:2.3:test [INFO] | \- cglib:cglib-nodep:jar:2.1_3:test [INFO] +- xmlunit:xmlunit:jar:1.2:test [INFO] +- junit:junit:jar:4.4:test [INFO] +- org.apache.ws.commons.schema:XmlSchema:jar:1.4.2:compile [INFO] +- org.springframework:spring-test:jar:2.5.6:test [INFO] \- au.edu.qut.qutvirtual.unitservice:unitservice-testhelpers:jar:1.2.2-SNAPSHOT:test [INFO] \- org.testng:testng:jar:jdk15:5.8:test
          Hide
          arjen.poutsma Arjen Poutsma added a comment - - edited

          As I suspected, this is a JDOM or SAAJ bug, as I was able to reproduce it without using any Spring-WS code:

          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
          SOAPBody body = message.getSOAPBody();
          SOAPElement payload = null;
          for (Iterator iterator = body.getChildElements(); iterator.hasNext();) {
              Object child = iterator.next();
              if (child instanceof SOAPElement) {
                  payload = (SOAPElement) child;
                  break;
              }
          }
          Source source = new DOMSource(payload);
          Result result = new JDOMResult();
          // result = new StringResult(); // using the Spring StringResult works just fine
          newTransformer.transform(saajSoapMessage.getPayloadSource(), result); // this line throws the exception

          My bet would be that JDOM is the culprit. I did upgrade to JDOM 1.1 from 1.0, but that didn't help either. You could try using dom4j or xom instead.

          Show
          arjen.poutsma Arjen Poutsma added a comment - - edited As I suspected, this is a JDOM or SAAJ bug, as I was able to reproduce it without using any Spring-WS code: 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 SOAPBody body = message.getSOAPBody(); SOAPElement payload = null; for (Iterator iterator = body.getChildElements(); iterator.hasNext();) { Object child = iterator.next(); if (child instanceof SOAPElement) { payload = (SOAPElement) child; break; } } Source source = new DOMSource(payload); Result result = new JDOMResult(); // result = new StringResult(); // using the Spring StringResult works just fine newTransformer.transform(saajSoapMessage.getPayloadSource(), result); // this line throws the exception My bet would be that JDOM is the culprit. I did upgrade to JDOM 1.1 from 1.0, but that didn't help either. You could try using dom4j or xom instead.
          Hide
          arjen.poutsma Arjen Poutsma added a comment -

          Resolving as won't fix, because we can't fix.

          Show
          arjen.poutsma Arjen Poutsma added a comment - Resolving as won't fix, because we can't fix.
          Hide
          arjen.poutsma Arjen Poutsma added a comment -

          Closing old issues

          Show
          arjen.poutsma Arjen Poutsma added a comment - Closing old issues

            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: