Uploaded image for project: 'JBoss Web Services'
  1. JBoss Web Services
  2. JBWS-2345

SOAPBody.getElementsByTagName() returns an empty NodeList

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • Minor
    • None
    • jbossws-native-3.0.1
    • jbossws-native
    • None

    Description

      SOAPHandler uses SOAPMessageContext to get SOAPMessage.
      Then get SOAPBody via SOAPMessage.getSOAPBody().
      Since SOAPBody extends org.w3c.dom.Element, use the following to get at <arg0>
      Element arg0Element = (Element) body.getElementsByTagName("arg0").item(0);
      System.out.println("arg0Element is null: " + (arg0Element == null)); // IT'S NULL

      Here's the code:
      public boolean handleMessage(SOAPMessageContext msgContext)
      {
      try

      { // see what's coming in System.out.println("------INCOMING---------"); SOAPMessage message = msgContext.getMessage(); message.writeTo(System.out); System.out.println("------------------------"); // get <arg0> SOAPBody body = message.getSOAPBody(); Element arg0Element = (Element) body.getElementsByTagName("arg0").item(0); System.out.println("arg0Element is null: " + (arg0Element == null)); // IT'S NULL ... }

      }

      Here's the output:
      -----INCOMING--------
      <soapenv:Envelope xmlns:jcat='http://catalog.javatunes.com/' xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'><soapenv:Body><jcat:findByKeyword xmlns:jcat='http://catalog.javatunes.com/'><arg0>nn
      </arg0>
      </jcat:findByKeyword>
      </soapenv:Body></soapenv:Envelope>
      ------------------------
      arg0Element is null: true

      NOTE: the whitespace nodes in the message are added by JBoss somewhere, the source message contained no whitespace. (Shouldn't matter anyway.)
      You can see that <soapenv:Body> indeed has an <arg0> element (in no namespace).
      I also tried this with <jcat:findByKeyword> using both getElementsByTagName and getElementsByTagNameNS, both yielding same result.

      Attachments

        Issue Links

          Activity

            People

              rhn-support-asoldano Alessio Soldano
              jrostosk_jira Jay Rostosky (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: