[jdom-interest] Reading from SOAP

Nicolàs de Hilster nicolas at globalxion.nl
Mon May 6 06:01:24 PDT 2002


Hi there,
 
We are currently involved in a XML project. All messages will be sent
and received in a SOAP-envelope.
Now I tried to read from this SOAP-envelope using JDOM and managed to
read until I get to the content of
The <soap:Body> element. Within this element all elements have a default
namespace without prefix
(see XML part at the bottom of this message).
 
When I use following code:
 
Namespace nsEAN = Namespace.getNamespace("http://www.ean.nl/");
Namespace nsSOAP =
Namespace.getNamespace("soap","http://schemas.xmlsoap.org/soap/envelope/
");
SAXBuilder builder = new
SAXBuilder("org.apache.xerces.parsers.SAXParser", true);
Document doc = builder.build(new File(dataFile));
Element el = doc.getRootElement();
            el=el.getChild("Body",nsSOAP);
            System.out.println(""+el.getContent());
 
I get the following:
 
[
                , [Element: <Order [Namespace: http://www.ean.nl]/>],
                , [Element: <Order [Namespace: http://www.ean.nl]/>],
                , [Element: <Order [Namespace: http://www.ean.nl]/>],
                , [Element: <Order [Namespace: http://www.ean.nl]/>],
        ]
 
So I can get the content of the <soap:Body> Element, but when I now try
to read a <Order> element using:
 
            el=el.getChild("Order",nsEAN);
or
            el=el.getChild("Order");
 
I get “null” in return
 
Obviously I do something wrong, so could you please explain to me how to
read further through this XML?
 
Best regards,
 
Nicolàs de Hilster
GlobalXion bv
 
 
<?xml version = "1.0" encoding = "UTF-8"?>
<soap:Envelope xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd = "http://www.w3.org/2001/XMLSchema" xmlns:soap =
"http://schemas.xmlsoap.org/soap/envelope/" xmlns = "http://www.ean.nl"
xsi:schemaLocation = "http://schemas.xmlsoap.org/soap/envelope/
./EnvelopWithMessages.xsd">
            <soap:Header>
            .
            .
            </soap:Header>
            <soap:Body>
                        <Order>
                                    <OrderHeader>
 
<OrderVersion>1.1</OrderVersion>
.
.
.
.
etc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://jdom.org/pipermail/jdom-interest/attachments/20020506/bb0e8b8d/attachment.htm


More information about the jdom-interest mailing list