<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2653.12">
<TITLE>newbie question: how to parse a soap message?</TITLE>
</HEAD>
<BODY>
<P><FONT SIZE=2 FACE="Arial">Hi all:</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">I have been using JDOM for a while but quite new to namespaces.. can anyone show me how to parse a SOAP message?</FONT>
</P>
<P><FONT COLOR="#0000FF" SIZE=2 FACE="Arial"><</FONT><FONT COLOR="#800000" SIZE=2 FACE="Arial">SOAP-ENV:Envelope</FONT><FONT COLOR="#FF0000" SIZE=2 FACE="Arial"> xmlns:e</FONT><FONT COLOR="#0000FF" SIZE=2 FACE="Arial">="</FONT><FONT COLOR="#000000" SIZE=2 FACE="Arial"><A HREF="http://www.lexisnexis.com/xml/gw3_0/faults/" TARGET="_blank">http://www.lexisnexis.com/xml/gw3_0/faults/</A></FONT><FONT COLOR="#0000FF" SIZE=2 FACE="Arial">"</FONT><FONT COLOR="#FF0000" SIZE=2 FACE="Arial"> xmlns:m</FONT><FONT COLOR="#0000FF" SIZE=2 FACE="Arial">="</FONT><FONT COLOR="#000000" SIZE=2 FACE="Arial"><A HREF="http://www.lexisnexis.com/xml/gw3_0/soap1_1/" TARGET="_blank">http://www.lexisnexis.com/xml/gw3_0/soap1_1/</A></FONT><FONT COLOR="#0000FF" SIZE=2 FACE="Arial">"</FONT><FONT COLOR="#FF0000" SIZE=2 FACE="Arial"> xmlns:xsd</FONT><FONT COLOR="#0000FF" SIZE=2 FACE="Arial">="</FONT><FONT COLOR="#000000" SIZE=2 FACE="Arial"><A HREF="http://www.w3.org/2001/XMLSchema" TARGET="_blank">http://www.w3.org/2001/XMLSchema</A></FONT><FONT COLOR="#0000FF" SIZE=2 FACE="Arial">"</FONT><FONT COLOR="#FF0000" SIZE=2 FACE="Arial"> xmlns:xsi</FONT><FONT COLOR="#0000FF" SIZE=2 FACE="Arial">="</FONT><FONT COLOR="#000000" SIZE=2 FACE="Arial"><A HREF="http://www.w3.org/2001/XMLSchema-instance" TARGET="_blank">http://www.w3.org/2001/XMLSchema-instance</A></FONT><FONT COLOR="#0000FF" SIZE=2 FACE="Arial">"</FONT><FONT COLOR="#FF0000" SIZE=2 FACE="Arial"> xmlns:SOAP-ENC</FONT><FONT COLOR="#0000FF" SIZE=2 FACE="Arial">="</FONT><FONT COLOR="#000000" SIZE=2 FACE="Arial"><A HREF="http://schemas.xmlsoap.org/soap/encoding/" TARGET="_blank">http://schemas.xmlsoap.org/soap/encoding/</A></FONT><FONT COLOR="#0000FF" SIZE=2 FACE="Arial">"</FONT><FONT COLOR="#FF0000" SIZE=2 FACE="Arial"> xmlns:SOAP-ENV</FONT><FONT COLOR="#0000FF" SIZE=2 FACE="Arial">="</FONT><FONT COLOR="#000000" SIZE=2 FACE="Arial"><A HREF="http://schemas.xmlsoap.org/soap/envelope/" TARGET="_blank">http://schemas.xmlsoap.org/soap/envelope/</A></FONT><FONT COLOR="#0000FF" SIZE=2 FACE="Arial">"></FONT></P>
<P> <FONT COLOR="#0000FF" SIZE=2 FACE="Arial"><</FONT><FONT COLOR="#800000" SIZE=2 FACE="Arial">SOAP-ENV:Header</FONT><FONT COLOR="#0000FF" SIZE=2 FACE="Arial">></FONT>
<BR> <FONT COLOR="#0000FF" SIZE=2 FACE="Arial"><</FONT><FONT COLOR="#800000" SIZE=2 FACE="Arial">m:preferredTransportEndpoint</FONT><FONT COLOR="#0000FF" SIZE=2 FACE="Arial">></FONT><FONT COLOR="#000000" SIZE=2 FACE="Arial"><A HREF="https://cert-grp1.lexis-nexis.com/xml/gw3_0/soap1_1?wchp" TARGET="_blank">https://cert-grp1.lexis-nexis.com/xml/gw3_0/soap1_1?wchp</A></FONT><FONT COLOR="#0000FF" SIZE=2 FACE="Arial">=</FONT><FONT COLOR="#000000" SIZE=2 FACE="Arial">LdLzzb-tAAAA</FONT><FONT COLOR="#0000FF" SIZE=2 FACE="Arial"></</FONT><FONT COLOR="#800000" SIZE=2 FACE="Arial">m:preferredTransportEndpoint</FONT><FONT COLOR="#0000FF" SIZE=2 FACE="Arial">></FONT></P>
<P> <FONT COLOR="#0000FF" SIZE=2 FACE="Arial"></</FONT><FONT COLOR="#800000" SIZE=2 FACE="Arial">SOAP-ENV:Header</FONT><FONT COLOR="#0000FF" SIZE=2 FACE="Arial">></FONT>
<BR> <FONT COLOR="#0000FF" SIZE=2 FACE="Arial"><</FONT><FONT COLOR="#800000" SIZE=2 FACE="Arial">SOAP-ENV:Body</FONT><FONT COLOR="#0000FF" SIZE=2 FACE="Arial">></FONT>
<BR> <FONT COLOR="#0000FF" SIZE=2 FACE="Arial"><</FONT><FONT COLOR="#800000" SIZE=2 FACE="Arial">m:AuthenticateResponse</FONT><FONT COLOR="#0000FF" SIZE=2 FACE="Arial">></FONT>
<BR> <FONT COLOR="#0000FF" SIZE=2 FACE="Arial"><</FONT><FONT COLOR="#800000" SIZE=2 FACE="Arial">m:authenticationToken</FONT><FONT COLOR="#0000FF" SIZE=2 FACE="Arial">></FONT><FONT COLOR="#000000" SIZE=2 FACE="Arial">b972d119b5fb025b1de9ca31a9d8b9d6</FONT><FONT COLOR="#0000FF" SIZE=2 FACE="Arial"></</FONT><FONT COLOR="#800000" SIZE=2 FACE="Arial">m:authenticationToken</FONT><FONT COLOR="#0000FF" SIZE=2 FACE="Arial">></FONT>
<BR> <FONT COLOR="#0000FF" SIZE=2 FACE="Arial"><</FONT><FONT COLOR="#800000" SIZE=2 FACE="Arial">m:tokenExpiration</FONT><FONT COLOR="#0000FF" SIZE=2 FACE="Arial">></FONT><FONT COLOR="#000000" SIZE=2 FACE="Arial">2002-09-18T15:32:16-04:00</FONT><FONT COLOR="#0000FF" SIZE=2 FACE="Arial"></</FONT><FONT COLOR="#800000" SIZE=2 FACE="Arial">m:tokenExpiration</FONT><FONT COLOR="#0000FF" SIZE=2 FACE="Arial">></FONT>
<BR> <FONT COLOR="#0000FF" SIZE=2 FACE="Arial"></</FONT><FONT COLOR="#800000" SIZE=2 FACE="Arial">m:AuthenticateResponse</FONT><FONT COLOR="#0000FF" SIZE=2 FACE="Arial">></FONT>
<BR> <FONT COLOR="#0000FF" SIZE=2 FACE="Arial"></</FONT><FONT COLOR="#800000" SIZE=2 FACE="Arial">SOAP-ENV:Body</FONT><FONT COLOR="#0000FF" SIZE=2 FACE="Arial">></FONT>
<BR><FONT COLOR="#0000FF" SIZE=2 FACE="Arial"></</FONT><FONT COLOR="#800000" SIZE=2 FACE="Arial">SOAP-ENV:Envelope</FONT><FONT COLOR="#0000FF" SIZE=2 FACE="Arial">></FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">I want to retrieve the authenticationToken.. and I tried:</FONT>
</P>
<P> <FONT SIZE=2 FACE="Arial">StringReader sreader = new StringReader(sb.toString()); //sb has the above XML document</FONT>
<BR> <FONT SIZE=2 FACE="Arial">Document doc = builder.build(sreader);</FONT>
<BR> <FONT SIZE=2 FACE="Arial">Namespace env_ns = Namespace.getNamespace("SOAP-ENV", "<A HREF="http://schemas.xmlsoap.org/soap/envelope/" TARGET="_blank">http://schemas.xmlsoap.org/soap/envelope/</A>");</FONT>
<BR> <FONT SIZE=2 FACE="Arial">Namespace m_ns = Namespace.getNamespace("m", "<A HREF="http://www.lexisnexis.com/xml/gw3_0/soap1_1/" TARGET="_blank">http://www.lexisnexis.com/xml/gw3_0/soap1_1/</A>");</FONT>
<BR> <FONT SIZE=2 FACE="Arial">Element root = doc.getRootElement();</FONT>
<BR> <FONT SIZE=2 FACE="Arial">String sid = root.getChild("Body", env_ns).getChild("AuthencticateResponse", m_ns).getChildText("AuthenticationToken", m_ns);</FONT></P>
<P><FONT SIZE=2 FACE="Arial">but I'm getting exceptions when I tried to parse it.. please help!</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">Thanks</FONT>
<BR>
<BR><FONT SIZE=2 FACE="Arial">Charlie</FONT>
</P>
</BODY>
</HTML>