<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE>newbie question: how to parse a soap message?</TITLE>
<META content="MSHTML 6.00.2600.0" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=193114020-17092002><FONT face=Arial color=#0000ff size=2>please
disregard this question.. typos :-(</FONT></SPAN></DIV>
<DIV><SPAN class=193114020-17092002><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=193114020-17092002><FONT face=Arial color=#0000ff size=2>sorry
for the spam</FONT></SPAN></DIV>
<DIV><SPAN class=193114020-17092002><FONT face=Arial color=#0000ff
size=2><BR>Charlie</FONT></SPAN></DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma
size=2>-----Original Message-----<BR><B>From:</B> Charlie Wu
[mailto:cwu@brocade.com]<BR><B>Sent:</B> Tuesday, September 17, 2002 1:28
PM<BR><B>To:</B> 'jdom-interest@jdom.org'<BR><B>Subject:</B> [jdom-interest]
newbie question: how to parse a soap message?<BR><BR></FONT></DIV>
<P><FONT face=Arial size=2>Hi all:</FONT> </P>
<P><FONT face=Arial size=2>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 face=Arial color=#0000ff size=2><</FONT><FONT face=Arial
color=#800000 size=2>SOAP-ENV:Envelope</FONT><FONT face=Arial color=#ff0000
size=2> xmlns:e</FONT><FONT face=Arial color=#0000ff size=2>="</FONT><FONT
face=Arial color=#000000 size=2><A
href="http://www.lexisnexis.com/xml/gw3_0/faults/"
target=_blank>http://www.lexisnexis.com/xml/gw3_0/faults/</A></FONT><FONT
face=Arial color=#0000ff size=2>"</FONT><FONT face=Arial color=#ff0000 size=2>
xmlns:m</FONT><FONT face=Arial color=#0000ff size=2>="</FONT><FONT face=Arial
color=#000000 size=2><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
face=Arial color=#0000ff size=2>"</FONT><FONT face=Arial color=#ff0000 size=2>
xmlns:xsd</FONT><FONT face=Arial color=#0000ff size=2>="</FONT><FONT
face=Arial color=#000000 size=2><A href="http://www.w3.org/2001/XMLSchema"
target=_blank>http://www.w3.org/2001/XMLSchema</A></FONT><FONT face=Arial
color=#0000ff size=2>"</FONT><FONT face=Arial color=#ff0000 size=2>
xmlns:xsi</FONT><FONT face=Arial color=#0000ff size=2>="</FONT><FONT
face=Arial color=#000000 size=2><A
href="http://www.w3.org/2001/XMLSchema-instance"
target=_blank>http://www.w3.org/2001/XMLSchema-instance</A></FONT><FONT
face=Arial color=#0000ff size=2>"</FONT><FONT face=Arial color=#ff0000 size=2>
xmlns:SOAP-ENC</FONT><FONT face=Arial color=#0000ff size=2>="</FONT><FONT
face=Arial color=#000000 size=2><A
href="http://schemas.xmlsoap.org/soap/encoding/"
target=_blank>http://schemas.xmlsoap.org/soap/encoding/</A></FONT><FONT
face=Arial color=#0000ff size=2>"</FONT><FONT face=Arial color=#ff0000 size=2>
xmlns:SOAP-ENV</FONT><FONT face=Arial color=#0000ff size=2>="</FONT><FONT
face=Arial color=#000000 size=2><A
href="http://schemas.xmlsoap.org/soap/envelope/"
target=_blank>http://schemas.xmlsoap.org/soap/envelope/</A></FONT><FONT
face=Arial color=#0000ff size=2>"></FONT></P>
<P> <FONT face=Arial color=#0000ff
size=2><</FONT><FONT face=Arial color=#800000
size=2>SOAP-ENV:Header</FONT><FONT face=Arial color=#0000ff size=2>></FONT>
<BR>
<FONT face=Arial color=#0000ff
size=2><</FONT><FONT face=Arial color=#800000
size=2>m:preferredTransportEndpoint</FONT><FONT face=Arial color=#0000ff
size=2>></FONT><FONT face=Arial color=#000000 size=2><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
face=Arial color=#0000ff size=2>=</FONT><FONT face=Arial color=#000000
size=2>LdLzzb-tAAAA</FONT><FONT face=Arial color=#0000ff
size=2></</FONT><FONT face=Arial color=#800000
size=2>m:preferredTransportEndpoint</FONT><FONT face=Arial color=#0000ff
size=2>></FONT></P>
<P> <FONT face=Arial color=#0000ff
size=2></</FONT><FONT face=Arial color=#800000
size=2>SOAP-ENV:Header</FONT><FONT face=Arial color=#0000ff size=2>></FONT>
<BR> <FONT face=Arial color=#0000ff
size=2><</FONT><FONT face=Arial color=#800000
size=2>SOAP-ENV:Body</FONT><FONT face=Arial color=#0000ff size=2>></FONT>
<BR>
<FONT face=Arial color=#0000ff
size=2><</FONT><FONT face=Arial color=#800000
size=2>m:AuthenticateResponse</FONT><FONT face=Arial color=#0000ff
size=2>></FONT> <BR>
<FONT face=Arial color=#0000ff
size=2><</FONT><FONT face=Arial color=#800000
size=2>m:authenticationToken</FONT><FONT face=Arial color=#0000ff
size=2>></FONT><FONT face=Arial color=#000000
size=2>b972d119b5fb025b1de9ca31a9d8b9d6</FONT><FONT face=Arial color=#0000ff
size=2></</FONT><FONT face=Arial color=#800000
size=2>m:authenticationToken</FONT><FONT face=Arial color=#0000ff
size=2>></FONT> <BR>
<FONT face=Arial color=#0000ff
size=2><</FONT><FONT face=Arial color=#800000
size=2>m:tokenExpiration</FONT><FONT face=Arial color=#0000ff
size=2>></FONT><FONT face=Arial color=#000000
size=2>2002-09-18T15:32:16-04:00</FONT><FONT face=Arial color=#0000ff
size=2></</FONT><FONT face=Arial color=#800000
size=2>m:tokenExpiration</FONT><FONT face=Arial color=#0000ff
size=2>></FONT> <BR>
<FONT face=Arial color=#0000ff
size=2></</FONT><FONT face=Arial color=#800000
size=2>m:AuthenticateResponse</FONT><FONT face=Arial color=#0000ff
size=2>></FONT> <BR> <FONT
face=Arial color=#0000ff size=2></</FONT><FONT face=Arial color=#800000
size=2>SOAP-ENV:Body</FONT><FONT face=Arial color=#0000ff size=2>></FONT>
<BR><FONT face=Arial color=#0000ff size=2></</FONT><FONT face=Arial
color=#800000 size=2>SOAP-ENV:Envelope</FONT><FONT face=Arial color=#0000ff
size=2>></FONT> </P>
<P><FONT face=Arial size=2>I want to retrieve the authenticationToken.. and I
tried:</FONT> </P>
<P>
<FONT face=Arial
size=2>StringReader sreader = new StringReader(sb.toString()); //sb has the
above XML document</FONT> <BR>
<FONT face=Arial size=2>Document
doc = builder.build(sreader);</FONT>
<BR>
<FONT face=Arial size=2>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 face=Arial size=2>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 face=Arial size=2>Element
root = doc.getRootElement();</FONT>
<BR>
<FONT face=Arial size=2>String sid
= root.getChild("Body", env_ns).getChild("AuthencticateResponse",
m_ns).getChildText("AuthenticationToken", m_ns);</FONT></P>
<P><FONT face=Arial size=2>but I'm getting exceptions when I tried to parse
it.. please help!</FONT> </P>
<P><FONT face=Arial size=2>Thanks</FONT> <BR><BR><FONT face=Arial
size=2>Charlie</FONT> </P></BLOCKQUOTE></BODY></HTML>