[jdom-interest] newbie question: how to parse a soap message?

Charlie Wu cwu at brocade.com
Tue Sep 17 13:28:22 PDT 2002


Hi all:

I have been using JDOM for a while but quite new to namespaces.. can anyone
show me how to parse a SOAP message?

<SOAP-ENV:Envelope xmlns:e="http://www.lexisnexis.com/xml/gw3_0/faults/"
xmlns:m="http://www.lexisnexis.com/xml/gw3_0/soap1_1/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
	<SOAP-ENV:Header>
	
<m:preferredTransportEndpoint>https://cert-grp1.lexis-nexis.com/xml/gw3_0/so
ap1_1?wchp=LdLzzb-tAAAA</m:preferredTransportEndpoint>
	</SOAP-ENV:Header>
	<SOAP-ENV:Body>
		<m:AuthenticateResponse>
	
<m:authenticationToken>b972d119b5fb025b1de9ca31a9d8b9d6</m:authenticationTok
en>
	
<m:tokenExpiration>2002-09-18T15:32:16-04:00</m:tokenExpiration>
		</m:AuthenticateResponse>
	</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

I want to retrieve the authenticationToken.. and I tried:

		StringReader sreader = new StringReader(sb.toString()); //sb
has the above XML document
		Document doc = builder.build(sreader);
		Namespace env_ns = Namespace.getNamespace("SOAP-ENV",
"http://schemas.xmlsoap.org/soap/envelope/");
		Namespace m_ns = Namespace.getNamespace("m",
"http://www.lexisnexis.com/xml/gw3_0/soap1_1/");
		Element root = doc.getRootElement();
		String sid = root.getChild("Body",
env_ns).getChild("AuthencticateResponse",
m_ns).getChildText("AuthenticationToken", m_ns);

but I'm getting exceptions when I tried to parse it.. please help!

Thanks

Charlie
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://jdom.org/pipermail/jdom-interest/attachments/20020917/a21620d3/attachment.htm


More information about the jdom-interest mailing list