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>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Im trying to parse the =
below&nbsp;reponse from my=20
nusoap web service. Everytime I try&nbsp;I get a parse exception. Can =
you=20
help?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Ben Bell</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</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>&lt;?xml version=3D"1.0"=20
encoding=3D"ISO-8859-1"?&gt;<BR>&lt;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>"&nbsp;=20
xmlns:SOAP-ENV=3D"<A=20
href=3D"http://schemas.xmlsoap.org/soap/envelope/">http://schemas.xmlsoap=
org/soap/envelope/</A>"&nbsp;=20
xmlns:xsd=3D"<A=20
href=3D"http://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchem=
a</A>"&nbsp;=20
xmlns:xsi=3D"<A=20
href=3D"http://www.w3.org/2001/XMLSchema-instance">http://www.w3.org/2001=
/XMLSchema-instance</A>"&nbsp;=20
xmlns:SOAP-ENC=3D"<A=20
href=3D"http://schemas.xmlsoap.org/soap/encoding/">http://schemas.xmlsoap=
org/soap/encoding/</A>"&nbsp;=20
xmlns:si=3D"<A=20
href=3D"http://soapinterop.org/xsd">http://soapinterop.org/xsd</A>"&gt;<B=
R>&lt;SOAP-ENV:Body&gt;<BR>&lt;addResponse&gt;<BR>&lt;soapVal=20
xsi:type=3D"xsd:int"&gt;27&lt;/soapVal&gt;<BR>&lt;/addResponse&gt;<BR>&lt=
;/SOAP-ENV:Body&gt;<BR>&lt;/SOAP-ENV:Envelope&gt;</FONT></DIV>
<DIV>&nbsp;</DIV></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><STRONG>PARSE =
CODE</STRONG></FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;ByteArrayInputStream bis =3D new=20
ByteArrayInputStream (response.getBytes ());<BR>&nbsp;InputStreamReader =
reader =3D=20
new InputStreamReader (bis);</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;XmlParser xp =3D new XmlParser=20
(reader);<BR>&nbsp;ClassMap cm =3D new ClassMap=20
(Soap.VER12);<BR>&nbsp;SoapEnvelope envelope =3D new SoapEnvelope=20
(cm);</FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2>&nbsp;try{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
envelope.parse (xp);<BR>&nbsp;}&nbsp;&nbsp; catch (IOException=20
io){<BR>&nbsp;&nbsp;DEBUG("Parsing Error: "+=20
io.toString());<BR>&nbsp;}</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>result =3D (String) =
envelope.getBody();</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</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 &lt;Envelope&gt; 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--