[jdom-interest] Namespace problem
David D. Lucas
ddlucas at lse.com
Thu Jul 18 13:55:45 PDT 2002
This may be a silly question, but are you sure you put the correct URI
name in the Namespace? Perhaps it does not have the ending slash "/"
after envelope. Also check for any misspellings.
My 2 cents. :-)
Dave
Frank Cohen wrote:
> I'm having a problem using the Element.getChild() method when the
> element uses a namespace with no prefix. The getChild() method seems to
> always return a null value. The XML document is a response to a SOAP
> request. I'm using Jython (the Java implementation of Python):
>
> builder = SAXBuilder()
> doc = builder.build( StringReader( response.toString() ) )
>
> envelopeElement = doc.getRootElement()
>
> soap_ns = Namespace.getNamespace
> ("soap", "http://schemas.xmlsoap.org/soap/envelope/")
>
> bodyElement = envelopeElement.getChild("Body", soap_ns)
>
> so_ns = Namespace.getNamespace( "", "http://www.serviceobjects.com")
>
> at this point in the script I try to get the child using:
>
> atmrespElement = bodyElement.getChild( "GetATMLocationsResponse",
> so_ns )
>
> this returns null.
>
> I try another technique by using getChildre():
>
> print "Body Children"
> bc = bodyElement.getChildren()
> for i in bc:
> print i, i.getNamespace()
>
> and this works. The i.getNamespace() returns:
>
> [Element: <GetATMLocationsResponse [Namespace:
> http://www.serviceobjects.com/]/>] [Namespace: prefix "" is mapped to
> URI "http://www.serviceobjects.com/"]
>
> Below is the XML document.
>
> Any help would be appreciated.
>
> Thanks.
>
> -Frank
>
> <?xml version="1.0" encoding="utf-8"?><soap:Envelope
> xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><GetATMLocations
> Response
> xmlns="http://www.serviceobjects.com/"><GetATMLocationsResult><ATM><Bank
>
>>BAHAR MARKET</Bank><Address>811 W. HAMILTON
>
> AV</Address><Location>N/A</Location><City>CAMPBELL</City><State>CA</Stat
> e><Zip>95008</Zip><Latitude>37.2788</Latitude><Longitude>121.9545</Longi
> tude><Notes>24-Hour Access</Notes></ATM><ATM><Bank>BANK OF
> AMERICA</Bank><Address>1875 S BASCOM AVE STE</Address><Location>THE
> PRUNEYARD
> OP</Location><City>CAMPBELL</City><State>CA</State><Zip>95008</Zip><Lati
> tude>37.2788</Latitude><Longitude>121.9545</Longitude><Notes>24-Hour
> Access</Notes></ATM><ATM><Bank>BANK OF AMERICA</Bank><Address>200 THE
> PRUNEYARD</Address><Location>THE
> PRUNEYARD</Location><City>CAMPBELL</City><State>CA</State><Zip>95008</Zi
> p><Latitude>37.2788</Latitude><Longitude>121.9545</Longitude><Notes>24-
> Hour Access</Notes></ATM><ATM><Bank>CHASEWOOD BANK</Bank><Address>1859
> BUCKNALL ROAD</Address><Location>LIQUOR & FOOD
> MART</Location><City>CAMPBELL</City><State>CA</State><Zip>95008</Zip><La
> titude>37.2788</Latitude><Longitude>121.9545</Longitude><Notes>24-Hour
> Access</Notes></ATM><ATM><Bank>DOWNEY SAVINGS</Bank><Address>1480 W.
> CAMPBELL
> AVE.</Address><Location>N/A</Location><City>CAMPBELL</City><State>CA</St
> ate><Zip>95008</Zip><Latitude>37.2788</Latitude><Longitude>121.9545</Lon
> gitude><Notes>24-Hour Access</Notes></ATM><ATM><Bank>EDS/7-11 SAN
> FRANCISCO/SACRAMENTO</Bank><Address>262 W.SUNNY
> OAKS</Address><Location>N/A</Location><City>CAMPBELL</City><State>CA</St
> ate><Zip>95008</Zip><Latitude>37.2788</Latitude><Longitude>121.9545</Lon
> gitude><Notes>24-Hour
> Access</Notes></ATM><ATM><Bank>EUREKABANK</Bank><Address>750 WEST
> HAMILTON
> AVENUE</Address><Location>N/A</Location><City>CAMPBELL</City><State>CA</
> State><Zip>95008</Zip><Latitude>37.2788</Latitude><Longitude>121.9545</L
> ongitude><Notes>24-Hour Access</Notes></ATM><ATM><Bank>FIRST BANK &
> TRUST</Bank><Address>790 E CAMPBELL
> AVE</Address><Location>N/A</Location><City>CAMPBELL</City><State>CA</Sta
> te><Zip>95008</Zip><Latitude>37.2788</Latitude><Longitude>121.9545</Long
> itude><Notes>24-Hour Access</Notes></ATM><ATM><Bank>SAFEAMERICA FEDERAL
> CREDIT UNION</Bank><Address>1530 HAMILTON
> AVE.</Address><Location>SAFEWAY</Location><City>CAMPBELL</City><State>CA
> </State><Zip>95008</Zip><Latitude>37.2788</Latitude><Longitude>121.9545<
> /Longitude><Notes>24-Hour Access</Notes></ATM><ATM><Bank>TAQUERIA
> LOS</Bank><Address>1581 W
> CAMPBELL</Address><Location>N/A</Location><City>CAMPBELL</City><State>CA
> </State><Zip>95008</Zip><Latitude>37.2788</Latitude><Longitude>121.9545<
> /Longitude><Notes>24-Hour
> Access</Notes></ATM></GetATMLocationsResult></GetATMLocationsResponse></
> soap:Body></soap:Envelope>
>
>
>
> --
> http://www.PushToTest.com for free testing tools for testing Web
> Services
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com
>
--
+------------------------------------------------------------+
| David Lucas mailto:ddlucas at lse.com |
| Lucas Software Engineering, Inc. (740) 964-6248 Voice |
| Unix,Java,C++,CORBA,XML,EJB (614) 668-4020 Mobile |
| Middleware,Frameworks (888) 866-4728 Fax/Msg |
+------------------------------------------------------------+
| GPS Location: 40.0150 deg Lat, -82.6378 deg Long |
| IMHC: "Jesus Christ is the way, the truth, and the life." |
| IMHC: "I know where I am; I know where I'm going." <>< |
+------------------------------------------------------------+
Notes: PGP Key Block=http://www.lse.com/~ddlucas/pgpblock.txt
IMHO="in my humble opinion" IMHC="in my humble conviction"
All trademarks above are those of their respective owners.
More information about the jdom-interest
mailing list