[
https://issues.apache.org/jira/browse/AXIS2-3050?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12517506
]
sumedha rubasinghe commented on AXIS2-3050:
-------------------------------------------
Hi JF,
I have modified the code to include indents & some spaces. Please take a note
of how I access the the Element after SOAPBody element. From what I learned
spaces are treated as Text nodes. That is why you got "\n" in the first place.
Hope this helps....
/sumedha
>>>>>>>>>>>>>
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.Iterator;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPMessage;
public class Axis3050 {
public static void main(String[] args) {
String s =
"<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
" <soapenv:Envelope
xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"> " +
" <soapenv:Body> " +
" <get_registryInfo generic=\"1.0\"
xmlns=\"urn:juddi-org:api_v2\"/> " +
" </soapenv:Body> " +
"</soapenv:Envelope> ";
MessageFactory msgFactory;
try {
msgFactory = MessageFactory.newInstance();
SOAPMessage soapReq = msgFactory.createMessage(null,new
ByteArrayInputStream(s.getBytes()));
SOAPBody soapReqBody = soapReq.getSOAPBody();
//Node n = soapReqBody.getFirstChild();
Iterator itrChildElements =
soapReqBody.getChildElements();
while (itrChildElements.hasNext()) {
Object obj = (Object) itrChildElements.next();
if (obj instanceof SOAPElement){
SOAPElement soapElement = (SOAPElement)
obj;
System.out.println(soapElement.getNodeName());
System.out.println(soapElement.getAttributes().getLength());
}
}
} catch (SOAPException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
> Reading indented XML using SAAJ (which uses AXIOM) treats line breaks and
> spaces as text nodes
> ----------------------------------------------------------------------------------------------
>
> Key: AXIS2-3050
> URL: https://issues.apache.org/jira/browse/AXIS2-3050
> Project: Axis 2.0 (Axis2)
> Issue Type: Bug
> Components: om
> Affects Versions: 1.3
> Environment: All
> Reporter: Jeff Faath
> Assignee: sumedha rubasinghe
> Priority: Minor
>
> I am trying to read this XML snippet:
> <?xml version="1.0" encoding="utf-8"?>
> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
> <soapenv:Body>
> <get_registryInfo generic="1.0" xmlns="urn:juddi-org:api_v2"/>
> </soapenv:Body>
> </soapenv:Envelope>
> Using this code to read in and process:
> String s = <the xml snippet>
> MessageFactory msgFactory = MessageFactory.newInstance();
> SOAPMessage soapReq = msgFactory.createMessage(null,new
> ByteArrayInputStream(s.getBytes()));
> SOAPBody soapReqBody = soapReq.getSOAPBody();
> Then, on this line:
> Node n = soapReqBody.getFirstChild();
> The node returned on this call is a Text node with a value of "\n " (line
> break with spaces). In other words, the code handles the indenting up until
> the SOAPBody element is isolated. Then calling the getFirstChild() method
> returns the indenting as a Text node. Stepping into the code reveals that
> the getFirstChild() method comes from SAAJ's SOAPElementImpl. This in turn
> calls getFirstChild() from it's element member variable which is of type
> SOAP11BodyImpl from AXIOM. It is this call that is returning the indentation.
> Not sure if this is a bug or if AXIOM doesn't allow indented XML.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]