aspose file tools*
The moose likes Java Micro Edition and the fly likes Please help me with ksoap! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "Please help me with ksoap!" Watch "Please help me with ksoap!" New topic
Author

Please help me with ksoap!

Francesco Ferri
Greenhorn

Joined: Nov 18, 2004
Posts: 3
By! I'm writing an application using J2WTK2.1 that access to a web service. Using emulator I don't have any problem... Testing application on my sony-ericsson k700i is thown an exception like this:

org.kxml.parser.XmlParser$DefaultParserException: java.lang.RuntimeException: Method not supported for the given event type! @2:176
java.lang.RuntimeException: Method not supported for the given event type!

Can anyone help me?

I reinstalled application many times, three times has ran correctly, 1000 times no! Why??!! I don't have network problem (good GPRS signal). The sample application StockQuote downloaded from ksoap site have the same problem...

I tried whit JSR 172 API (with J2WTK2.1 it's all ok), but I can't use libraries whith package "java.", "javax.", "com.sun.", any suggestion? I used the obfuscator but nothing...

I don't have any other idea.... please help me!!! It's possible that my phone can't support ksoap?

Thanks, Francesco. (sorry for my english...)
Francesco Ferri
Greenhorn

Joined: Nov 18, 2004
Posts: 3
I have investigated about ksoap and exception

"Method not supported for the given event type!"

The source of class org.kxml.parser.ParseEvent is:

/* kXML
*
* The contents of this file are subject to the Enhydra Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License
* on the Enhydra web site ( http://www.enhydra.org/ ).
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific terms governing rights and limitations
* under the License.
*
* The Initial Developer of kXML is Stefan Haustein. Copyright (C)
* 2000, 2001 Stefan Haustein, D-46045 Oberhausen (Rhld.),
* Germany. All Rights Reserved.
*
* Contributor(s): Paul Palaszewski, Wilhelm Fitzpatrick,
* Eric Foster-Johnson
*
* */

package org.kxml.parser;

import java.util.*;
import java.io.IOException;

import org.kxml.*;


/** Abstract superclass for all pull parser events. In order to avoid
some typecasts, this class already provides most of the content
access methods filled in the specialized subclasses. */


public class ParseEvent {

static final String WRONG_TYPE =
"Method not supported for the given event type!";


int lineNumber = -1;
int type;
String text;

public ParseEvent (int type, String text) {
this.type = type;
this.text = text;
}


/** returns the line number of the event */

public int getLineNumber () {
return lineNumber;
}

/** returns the event type integer constant assigned to this
event. Possible event types are Xml.START_TAG, Xml.END_TAG,
Xml.TEXT, Xml.PROCESSING_INSTRUCTION, Xml.COMMENT,
Xml.DOCTYPE, and Xml.END_DOCUMENT */

public int getType () {
return type;
}


/** sets the line number of the event. Used by the parser only. */

public void setLineNumber (int lineNumber) {
this.lineNumber = lineNumber;
}


/** In the event type is START_TAG, this method returns the attribute
at the given index position. For all other event
types, or if the index is out of range, an exception is thrown. */


public Attribute getAttribute (int index) {
return (Attribute) getAttributes().elementAt (index);
}

/** returns the local attribute with the given name. convenience
method for getAttribute (Xml.NO_NAMESPACE, name); */

public Attribute getAttribute (String name) {
return getAttribute (Xml.NO_NAMESPACE, name);
}


/** returns the local attribute with the given qualified name.
Please use null as placeholder for any namespace or
Xml.NO_NAMESPACE for no namespace. */

public Attribute getAttribute (String namespace, String name) {

Vector attributes = getAttributes ();
int len = getAttributeCount ();

for (int i = 0; i < len; i++) {
Attribute attr = (Attribute) attributes.elementAt (i);

if (attr.getName ().equals (name)
&& (namespace == null || namespace.equals (attr.getNamespace ())))

return attr;
}

return null;
}


/** If the event type is START_TAG, the number of attributes is
returned. For all other event types, an exception is thrown. */

public int getAttributeCount () {
Vector a = getAttributes ();
return a == null ? 0 : a.size ();
}


/** If the event type is START_TAG, the attribute Vector (null if
no attributes) is returned. For all other event types, an
exception is thrown. */

public Vector getAttributes () {
throw new RuntimeException (WRONG_TYPE);
}

/** returns the (local) name of the element started if
instance of StartTag, null otherwise. */

public String getName () {
return null;
}


/** returns namespace if instance of StartTag, null
otherwise. */

public String getNamespace () {
return null;
}


/** Returns the value of the attribute with the given name.
Throws an exception if not instanceof StartTag or if not
existing. In order to get a null value for not existing
attributes, please call getValueDefault (attrName, null)
instead. */

public String getValue (String attrName) {
Attribute attr = getAttribute (attrName);
if (attr == null) throw new RuntimeException
("Attribute "+ attrName + " in " + this + " expected!");
return attr.getValue ();
}


/** Returns the given attribute value, or the given default value
if the attribute is not existing. */

public String getValueDefault (String attrName, String deflt) {
Attribute attr = getAttribute (attrName);
return attr == null ? deflt : attr.getValue ();
}


/** If the event type is TEXT, PROCESSING_INSTRUCTION,
or DOCTYPE, the corresponding string is returned. For
all othe event types, null is returned. */

public String getText () {
return text;
}



public String toString () {
return "ParseEvent type="+type+ " text='"+text+"'";
}
}

The only method getAttributes() thro every time an exception! ...why in the emulator it work correctly!!!??? The strange thing are that when I install the midlet in my k700i the first time work fine, after first run throw the exception. If I reinstall midlet work correctly only the first time!!

Why??? Please help me!
Michael Yuan
author
Ranch Hand

Joined: Mar 07, 2002
Posts: 1427
Fra Fra,

Welcome to JavaRanch. Please change your display name to conform to our naming policy, which you had agreed to when you signed up.

As for your problem with ksoap, it is mostly likely caused by the way the network sends HTTP to the device. For example, the network might break up the response into "chunks" and you can not read the entire response in one "read()" call. It is normally not a problem in emulators since the emulator does not run on wireless networks.


Seam Framework: http://www.amazon.com/exec/obidos/ASIN/0137129394/mobileenterpr-20/
Ringful: http://www.ringful.com/
Francesco Ferri
Greenhorn

Joined: Nov 18, 2004
Posts: 3
Thanks for reply...

...but why the first time I lanch my Midlet it run crrectly?!

This code for example don't use any connection to the network, it run local to the phone, but is affected by the same problem...


import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.io.*;
import org.ksoap.*;
import org.kxml.parser.*;

public class TestMidlet extends MIDlet implements CommandListener, Runnable
{

Form mainForm = new Form ("TestMidlet");
Command testCommand = new Command ("Test", Command.SCREEN, 1);
Command exitCommand = new Command ("Exit", Command.EXIT, 1);

public TestMidlet () {
mainForm.addCommand (testCommand);
mainForm.addCommand(exitCommand);
mainForm.setCommandListener (this);
}

public void startApp () {
Display.getDisplay (this).setCurrent (mainForm);
}

public void pauseApp () {
notifyPaused();
}

public void destroyApp (boolean unconditional) {
notifyDestroyed();
}

public void commandAction (Command c, Displayable d) {
if(c == this.testCommand){
new Thread(this).start();
}
else if(c == exitCommand){
destroyApp(true);
}
}

public void run(){
try{
String soap="<?xml version=\"1.0\"
encoding=\"UTF-8\"?><soapenv:Envelope
xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"
xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><soapenv:Body><ns1:g
etNumeroPuntiDiVenditaResponse
soapenv:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"
xmlns:ns1=\"http://DefaultNamespace\"><getNumeroPuntiDiVenditaReturn
xsi:type=\"xsd:int\">35</getNumeroPuntiDiVenditaReturn></ns1:getNumeroPuntiD
iVenditaResponse></soapenv:Body></soapenv:Envelope>";
InputStreamReader isr=new InputStreamReader(new
ByteArrayInputStream(soap.getBytes()));
XmlParser xmlparser = new XmlParser(isr);
SoapEnvelope responseEnvelope=new SoapEnvelope();

this.mainForm.append("Start parsing\n");
responseEnvelope.parse(xmlparser);
this.mainForm.append("End parsing\n");
}
catch(Exception e){
mainForm.append(e.toString ());
}
}
}

I think that my sony-ericsson k700i (or all k700i) has a bug in JVM... in fact with a nokia (Java enabled) both the example posted and my application (using HttpConnection) run correctly.

N.B. I have changed my name... sorry!

By, Francesco.
Fahad Aijaz
Greenhorn

Joined: Jul 04, 2005
Posts: 2
Originally posted by Michael Yuan:
Fra Fra,

Welcome to JavaRanch. Please change your display name to conform to our naming policy, which you had agreed to when you signed up.

As for your problem with ksoap, it is mostly likely caused by the way the network sends HTTP to the device. For example, the network might break up the response into "chunks" and you can not read the entire response in one "read()" call. It is normally not a problem in emulators since the emulator does not run on wireless networks.


Dear Michael,

I really am a java lover and JBoss has always inspired me with the opensource inovation it provides to us. Currenty I am working on one J2ME project for the first time and have encountered a problem that i am not able to figure out till now . Can you please help, I will really appreciate. Plz find the details below and it would be gr8 if you could respond me on fahadaijaz.lists@gmail.com . Thanks in advance.

If I have received the following xml from the client via UDP:

<SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing">
<SOAP-ENV:Header>
<wsa:To>datagram://127.0.0.1:9090/soaprpc</wsa:To>
<wsa:Action>urn:Services#echoString</wsa:Action>
<wsa:MessageId>uuid:95946541-2ce-d590dbc-22e14a74</wsa:MessageId>
<wsa:ReplyTo>
<wsa:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:Address>
</wsa:ReplyTo>
</SOAP-ENV:Header>
<SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<echoString xmlns="urn:Services" id="o0" SOAP-ENC:root="1">
<String xmlns="" xsi:type="xsd:string">a</String>
</echoString>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Do you have any idea (or can see what i cannot may be :S) what could be the cause of the following exception when I use the method extractRoot(..) pasted below, to parse it? I am using kXML in J2ME environment and receiving the packet via Selective Repeat ARQ mechanism.

org.kxml.parser.XmlParser$DefaultParserException: Attribute name ressmust be followed by '='! @8:1764
at org.kxml.parser.XmlParser.parseStartTag(+169)
at org.kxml.parser.XmlParser.parseSpecial(+145)
at org.kxml.parser.XmlParser.peek(+106)
at org.kxml.kdom.Node.parse(+6)
at org.kxml.kdom.Element.parse(+45)
at org.kxml.kdom.Node.parse(+80)
at org.kxml.kdom.Element.parse(+45)
at org.kxml.kdom.Node.parse(+80)
at org.kxml.kdom.Element.parse(+45)
at org.kxml.kdom.Node.parse(+80)
at org.kxml.kdom.Document.parse(+5)
at cnsoap.server.UDPServerThread.extractRoot(+45)
at cnsoap.server.UDPServerThread.await(+794)
at cnsoap.server.UDPServerThread.run(+9)

private void extractRoot(Datagram incomingPacket) throws IOException {

// incomingPacket.getData() returns the xml I have pasted above
InputStreamReader reader = new InputStreamReader (new ByteArrayInputStream(incomingPacket.getData()));
XmlParser xp = new XmlParser(reader);
Document doc = new Document();
doc.parse(xp);
root = doc.getRootElement(); // root is an instance member of the class
}

Greetings,

Fahad
fahadaijaz.lists@gmail.com
anan
Greenhorn

Joined: May 09, 2007
Posts: 1
Hi Francesco Ferri,

I am suffering with the same problem. Have you found any solution for this...

Am in a very confused state, can you please help me...............
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Please help me with ksoap!