Parsing nusoap response
"Ben BELL" <[email protected]> Mon, 8 Mar 2004 17:57:45 -0000
| Newsgroups | gmane.comp.java.enhydra.ksoap |
|---|---|
| Message-ID | <[email protected]> |
This is a multi-part message in MIME format.
------=_NextPart_000_000B_01C40536.DC4CF3A0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi Ksoap,
Im trying to parse the below reponse from my nusoap web service. =
Everytime I try I get a parse exception. Can you help?
Ben Bell
NUSOAP RESPONSE
<?xml version=3D"1.0" encoding=3D"ISO-8859-1"?>
<SOAP-ENV:Envelope=20
SOAP-ENV:encodingStyle=3D"http://schemas.xmlsoap.org/soap/encoding/" =
xmlns:SOAP-ENV=3D"http://schemas.xmlsoap.org/soap/envelope/" =
xmlns:xsd=3D"http://www.w3.org/2001/XMLSchema" =
xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance" =
xmlns:SOAP-ENC=3D"http://schemas.xmlsoap.org/soap/encoding/" =
xmlns:si=3D"http://soapinterop.org/xsd">
<SOAP-ENV:Body>
<addResponse>
<soapVal xsi:type=3D"xsd:int">27</soapVal>
</addResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
PARSE CODE
ByteArrayInputStream bis =3D new ByteArrayInputStream =
(response.getBytes ());
InputStreamReader reader =3D new InputStreamReader (bis);
XmlParser xp =3D new XmlParser (reader);
ClassMap cm =3D new ClassMap (Soap.VER12);
SoapEnvelope envelope =3D new SoapEnvelope (cm);
try{
envelope.parse (xp);
} catch (IOException io){
DEBUG("Parsing Error: "+ io.toString());
}
result =3D (String) envelope.getBody();
ERROR MSG
Parsing Error: org.kxml.io.ParseException: unexpected: StartTag =
<Envelope> line: -1 attr: =
[{http://schemas.xmlsoap.org/soap/envelope/}encodingStyle=3D"http://schem=
as.xmlsoap.org/soap/encoding/"] @-1:-1
------=_NextPart_000_000B_01C40536.DC4CF3A0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1400" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi Ksoap,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Im trying to parse the =
below reponse from my=20
nusoap web service. Everytime I try I get a parse exception. Can =
you=20
help?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Ben Bell</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>
<DIV><FONT face=3DArial size=3D2><STRONG>NUSOAP =
RESPONSE</STRONG></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><?xml version=3D"1.0"=20
encoding=3D"ISO-8859-1"?><BR><SOAP-ENV:Envelope=20
<BR>SOAP-ENV:encodingStyle=3D"<A=20
href=3D"http://schemas.xmlsoap.org/soap/encoding/">http://schemas.xmlsoap=
org/soap/encoding/</A>" =20
xmlns:SOAP-ENV=3D"<A=20
href=3D"http://schemas.xmlsoap.org/soap/envelope/">http://schemas.xmlsoap=
org/soap/envelope/</A>" =20
xmlns:xsd=3D"<A=20
href=3D"http://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchem=
a</A>" =20
xmlns:xsi=3D"<A=20
href=3D"http://www.w3.org/2001/XMLSchema-instance">http://www.w3.org/2001=
/XMLSchema-instance</A>" =20
xmlns:SOAP-ENC=3D"<A=20
href=3D"http://schemas.xmlsoap.org/soap/encoding/">http://schemas.xmlsoap=
org/soap/encoding/</A>" =20
xmlns:si=3D"<A=20
href=3D"http://soapinterop.org/xsd">http://soapinterop.org/xsd</A>"><B=
R><SOAP-ENV:Body><BR><addResponse><BR><soapVal=20
xsi:type=3D"xsd:int">27</soapVal><BR></addResponse><BR><=
;/SOAP-ENV:Body><BR></SOAP-ENV:Envelope></FONT></DIV>
<DIV> </DIV></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><STRONG>PARSE =
CODE</STRONG></FONT></DIV>
<DIV><FONT face=3DArial size=3D2> ByteArrayInputStream bis =3D new=20
ByteArrayInputStream (response.getBytes ());<BR> InputStreamReader =
reader =3D=20
new InputStreamReader (bis);</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> XmlParser xp =3D new XmlParser=20
(reader);<BR> ClassMap cm =3D new ClassMap=20
(Soap.VER12);<BR> SoapEnvelope envelope =3D new SoapEnvelope=20
(cm);</FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2> try{<BR> =20
envelope.parse (xp);<BR> } catch (IOException=20
io){<BR> DEBUG("Parsing Error: "+=20
io.toString());<BR> }</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>result =3D (String) =
envelope.getBody();</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><STRONG>ERROR MSG</STRONG></FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Parsing Error: =
org.kxml.io.ParseException:=20
unexpected: StartTag <Envelope> line: -1 attr:=20
[{http://schemas.xmlsoap.org/soap/envelope/}encodingStyle=3D"<A=20
href=3D"http://schemas.xmlsoap.org/soap/encoding/">http://schemas.xmlsoap=
org/soap/encoding/</A>"]=20
@-1:-1</FONT></DIV></BODY></HTML>
------=_NextPart_000_000B_01C40536.DC4CF3A0--