• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

kSOAP tutorial

 
author
Posts: 1436
6
Python TypeScript Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My new article on JavaWorld
Access Web services from wireless devices
enjoy
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
I'm trying to use kSOAP 1.2 with J2ME for a school project and I also use your article.
I created a MIDlet and I defined a method to parse a SOAP
message (it's something easy, just for testing):

public void parseString()
{
String msg = "<SOAP-ENV:Envelope " + "xmlns:SOAP-ENV=\"http://www.w3.org/2001/12/soap- envelope\" " + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-ins tance\" " +"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"& gt;" +
"<SOAP-ENV:Body>" +
"<result>" +
"<message xsi:type=\"xsd:string\">Hello World</message>" +
"</result>" +
"</SOAP-ENV:Body>" +
"</SOAP-ENV:Envelope>";
try
{
ByteArrayInputStream is = new ByteArrayInputStream(msg.getBytes());
InputStreamReader isr = new InputStreamReader(is);
XmlParser parser = new XmlParser(isr);
SoapEnvelope envelope = new SoapEnvelope();//new ClassMap(Soap.VER12));
envelope.parse(parser);
String body = (String)envelope.getBody();
String result = (String)envelope.getResult(); System.out.println("Body="+body+";Result="+result );
}
catch(Exception e)
{
e.printStackTrace();
}
}

When I run this example, I get the following exception:

org.kxml.io.ParseException: unexpected: StartTag <Envelope> line: -1 attr: [] @-1:-1
at org.kxml.parser.AbstractXmlParser.read(+53)
at org.ksoap.SoapEnvelope.parseHead(+19)
at org.ksoap.SoapEnvelope.parse(+5)
at Main.parseString(+50)
at Main.startApp(+4)
at javax.microedition.midlet.MIDletProxy.startApp(+7 )
at com.sun.midp.midlet.Scheduler.schedule(+225)
at com.sun.midp.dev.DevMIDletSuiteImpl.schedule(+7)
at com.sun.midp.Main.runLocalClass(+20)
at com.sun.midp.Main.main(+68)


If create the SoapEnvelope object like this:
SoapEnvelope envelope = new SoapEnvelope(new ClassMap(Soap.VER12));
I get a ClassCastException.
I would appreciate any kind of help.
Thank you.
 
reply
    Bookmark Topic Watch Topic
  • New Topic