You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-user@ws.apache.org by Pete Roth <pr...@telemetrytech.net> on 2001/08/01 22:36:23 UTC

Xerces XML parsing SOAP response problem

I am using the XML returned from a soap call with a DOMParser to read the
information returned.  I have a SOAP method that returns a lot of data
(hence why I'm doing it this way) but right now I am trying to get it to
work with a simple SOAP method that returns one element of data.  The XML
returned that is passed to the Parser is listed below along with my client
snippet that attempts to navigate the XML tree and print out the result.
For some reason when I try and get the child of the "SOAP:Body" node, I get
a null pointer.  If I call hasChildNodes() on the body node, I get false
returned.  There is, if you look at the XML being parsed below, more data in
the Body.  

Does anyone know why this is happening?  What I could do to fix this?  Any
help would be greatly appreciated.

Thanks.

Pete


*************
XML that I am trying to parse
****************************************************************************
********************
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XM
LSchema">
  <soap:Body>
    <vnoc_doSOAPTestResponse
xmlns="http://telemetrytech.net/VnocngWebService">
      <vnoc_doSOAPTestResult>15</vnoc_doSOAPTestResult>
    </vnoc_doSOAPTestResponse>
  </soap:Body>
</soap:Envelope>


****************************************************************************
********************


*************
Client Snip
****************************************************************************
********************
//XML data is in the String "xmlString" at this point, if I print it out it
contains the needed
//data.

//Now create the DOM doc from the XML
DOMParser parser = new DOMParser();

parser.setFeature("http://apache.org/xml/features/validation/schema-full-che
cking",true);
parser.setFeature("http://apache.org/xml/features/validation/schema",true);
parser.setFeature("http://xml.org/sax/features/validation",true);
								
//parse the XML (xml is in the String "xmlString"
parser.parse(new InputSource(new StringReader(xmlString)));

Document doc = parser.getDocument();
Element root = doc.getDocumentElement();

System.out.print("root="+root.getNodeName()+" ");
System.out.println("xmlns:soap="+
                   root.getAttribute("xmlns:soap") + 
                   " hasChildren="+root.hasChildNodes());
System.out.println("
root.getFirstChild().getNodeName()="+root.getFirstChild().getNodeName());
System.out.println("
firstChildHasChildren?="+root.getFirstChild().hasChildNodes());
								

****************************************************************************
************




Peter Roth
Telemetry Technologies Inc.
p: 404.231.0021 ext. 1290
e: proth@TelemetryTech.net