All this is by design: * toString is designed to produce an XML fragment that is valid with respect to namespaces. Thus, when applied to the SOAP body, it needs to add a namespace declaration for the http://schemas.xmlsoap.org/soap/envelope/ namespace.
* getText returns the results as specified in the Javadoc [1]. Andreas [1] http://people.apache.org/~veithen/axiom/apidocs/org/apache/axiom/om/OMElement.html#getText() On Sun, Apr 25, 2010 at 07:20, Demetris <demet...@ece.neu.edu> wrote: > > Why is the Body print showing this > xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> > that belongs to the Envelope? And it seems that messes up the Iterator loop > that returns > nothng. I am missing something in the response content access? > > Thanks > > SOAPBody body = response.getEnvelope().getBody(); > System.out.println("Env: "+response.getEnvelope().toString()); > System.out.println("Body: > "+response.getEnvelope().getBody().toString()); > OMElement element = body.getFirstElement(); > System.out.println("First element: "+element.getText()); > > Iterator<?> values = body.getChildren(); > while (values.hasNext()) { > OMElement elem = (OMElement) values.next(); > System.out.println("Result: " + > elem.getText()); > } > > Env: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope > xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><ns:getBooksResponse > xmlns:ns="http://myBooksAxis2.axis2.apache.org"><ns:return>Software > Engineering</ns:return><ns:return>Limits of > Computation</ns:return><ns:return>Digital > Circuits</ns:return><ns:return>Disruptive > Technologies</ns:return><ns:return>Mobile > Computing</ns:return></ns:getBooksResponse></soapenv:Body></soapenv:Envelope> > > Body: <soapenv:Body > xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><ns:getBooksResponse > xmlns:ns="http://myBooksAxis2.axis2.apache.org"><ns:return>Software > Engineering</ns:return><ns:return>Limits of > Computation</ns:return><ns:return>Digital > Circuits</ns:return><ns:return>Disruptive > Technologies</ns:return><ns:return>Mobile > Computing</ns:return></ns:getBooksResponse></soapenv:Body> > > First element: <=== empty but it should't be > > --------------------------------------------------------------------- > To unsubscribe, e-mail: java-user-unsubscr...@axis.apache.org > For additional commands, e-mail: java-user-h...@axis.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscr...@axis.apache.org For additional commands, e-mail: java-user-h...@axis.apache.org