SOAPBody.getElementsByTagName() returns an empty NodeList
---------------------------------------------------------
Key: JBWS-2345
URL:
https://jira.jboss.org/jira/browse/JBWS-2345
Project: JBoss Web Services
Issue Type: Bug
Security Level: Public (Everyone can see)
Components: jbossws-native
Affects Versions: jbossws-native-3.0.1
Environment: JBoss 4.2.3 with jbossws-3.0.1-native-2.0.4.GA (the one that comes
with 4.2.3 out of the box)
Windows XP Professional 5.1 Service Pack 2
Reporter: jrostosk
Priority: Minor
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/'><...
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.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira