BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 05-12-2006, 09:10 AM   #1
itnwc
New Member
 
Join Date: Apr 2006
Model: 7100
Posts: 7
Default KSOAP and BlackBerry JDE

Please Login to Remove!

Hi,

when i try to build a project(library) in the JDE with only the file
ksoap2-j2me-full-2.1.0.jar i have this error:

org.kobjects.base64.Base64: Error!: Missing stack map at label: 165

Whats going wrong? How can I integrate the KSoap to the BalckBerry JDE?

Thanks for help in advance.
Offline  
Old 05-12-2006, 09:32 AM   #2
jfisher
CrackBerry Addict
 
Join Date: Jun 2005
Location: Manchester, UK
Model: BOLD
Carrier: t-mobile
Posts: 714
Default

is it preverified? i'm not sure what the error means; it's been ages since i tried to get the precompiled ksoap jar working with my apps.

i just import the source .java files and run from that instead, works fine.
Offline  
Old 05-12-2006, 10:13 AM   #3
itnwc
New Member
 
Join Date: Apr 2006
Model: 7100
Posts: 7
Default missing files

Thnkas for your fast feedback -

importing the java-files we have always problems missing some files,
can you send us an link to download the complete needed files?

Thanks in advance.
Offline  
Old 05-17-2006, 07:46 AM   #4
jfisher
CrackBerry Addict
 
Join Date: Jun 2005
Location: Manchester, UK
Model: BOLD
Carrier: t-mobile
Posts: 714
Default

hmm, it's been a while since i've had to do it but i do remember there were a couple of files missing from their release package ( i think it was httptransport.java ). ksoap with blackberry is a recurring enquiry on here and the official bb dev forums so when i get back from holiday (29th may) i'll create a working project accessing a simple webservice and zip the whole lot and post it.
Offline  
Old 05-18-2006, 03:39 AM   #5
itnwc
New Member
 
Join Date: Apr 2006
Model: 7100
Posts: 7
Default

i can create a project with the whole files of ksoap, but now i cann't connect to my dotnet web service, i know that the webservice from dotnet is a bit special, so i write the tags for [webmethode] in the webservice, but in the java code after the httptransport.call will directly output the exception, so i cann't get the result of soap message. here is my java code.


import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.system.*;

import java.util.*;

import org.ksoap2.*;
import org.ksoap2.serialization.*;
import org.ksoap2.transport.*;

public class StockQuoteDemo extends UiApplication
{
public static void main (String[] args)
{
StockQuoteDemo theApp = new StockQuoteDemo ();
theApp.enterEventDispatcher ();
}

public StockQuoteDemo ()
{
pushScreen (new StockQuoteScreen ());
doSOAP();
}

final class StockQuoteScreen extends MainScreen
{
LabelField resultItem;
BasicEditField symbolField;
ButtonField bf;

public StockQuoteScreen ()
{
LabelField title = new LabelField ("StockQuote Sample", LabelField.ELLIPSIS|LabelField.USE_ALL_WIDTH);
setTitle (title);

symbolField = new BasicEditField ("Stock Symbol ", "ORCL", 4, BasicEditField.EDITABLE|BasicEditField.FILTER_UPPE RCASE);
resultItem = new LabelField ("Stock Price", LabelField.ELLIPSIS|LabelField.USE_ALL_WIDTH);

bf = new ButtonField ("Get price", Field.FOCUSABLE);

add (symbolField);
add (resultItem);
add (bf);
}

public boolean onClose ()
{
Dialog.alert ("Goodbye!");
System.exit (0);
return true;
}
}
public void doSOAP()
{
try
{
System.out.println("i am here 1");

SoapObject rpc = new SoapObject ("url...", "getInfo1");

rpc.addProperty("userstr","itnwc");

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.bodyOut = rpc;
envelope.dotNet = true;
envelope.encodingStyle = SoapSerializationEnvelope.ENC;

HttpTransport ht = new HttpTransport ("http:...localhost/Server2BB_WebService/Server2BBWebservice.asmx");
//ht.debug = true;
System.out.println("i am here 2");
ht.call("http:...tempuri.org/getInfo1",envelope);
System.out.println(envelope.toString());
System.out.println(envelope.getResult());

}

catch (Exception e)
{
System.out.println("i am here in catch");
e.printStackTrace ();

}
}
}


************************************************** *******
and my web service is as following:

<WebMethod(), SoapRpcMethod()> _
Public Function getInfo1(ByVal userstr As String) As String
Return "Hier kommt etwas Text " & userstr
End Function

what's wrong with the code?

thanks in advance
Offline  
Old 05-21-2006, 06:37 PM   #6
everettwolf
New Member
 
Join Date: May 2006
Model: 7520
Posts: 4
Default

itnwc, there's nothing wrong with your code. the ksoap source code is an absolute mess, and to get a working example is near impossible.

i guarantee you (this is a challenge), no one out there can give you a snippet of code that can make a soap call to a .net webservice passing a parameter, returning a result.

it can't be done. :o) (in other words, i want someone to prove me wrong)
Offline  
Old 05-21-2006, 07:25 PM   #7
everettwolf
New Member
 
Join Date: May 2006
Model: 7520
Posts: 4
Default got it to work

got it to work. if you want to know how, cut and paste your java code and webservice code EXACTLY how it looks and i'll try to fix it. or, better yet, send me a private email via this forum and i will send you the entirety of my code which works (including the soap source libraries which are a pain in the ASS to arrange and compile properly, and get to work on an actual blackberry device.)
Offline  
Old 05-23-2006, 03:07 AM   #8
jfisher
CrackBerry Addict
 
Join Date: Jun 2005
Location: Manchester, UK
Model: BOLD
Carrier: t-mobile
Posts: 714
Default

of course you can use a .net webservice, you just have to make sure that the webservice is standards compliant and doesn't include any of microsofts additions (which although sometimes elegant and useful; aren't standard).
Offline  
Old 05-23-2006, 10:07 AM   #9
jfisher
CrackBerry Addict
 
Join Date: Jun 2005
Location: Manchester, UK
Model: BOLD
Carrier: t-mobile
Posts: 714
Default

here's a working ksoap 1.0 project that uses googles api:

http://sundaracommunications.net/dow.../googleapi.zip

just unzip and open into a workspace in the jde, you'll need to obtain a google dev key from: http://www.google.com/apis/index.html to run it.

if you find any problems or find this useful let me know, i'll wait until i get some feedback before writing this up into a tutorial. the code could probably do with some tightening up too but i've rushed it this afternoon in my dinner break.

launch the app, enter a word and hit submit - the idea is to enter an incorrectly spelled word - hopefully google will return a spelling suggestion. this is a bare-bones app and made as simple as possible, if i do a write-up of this (as webservice questions come up a lot) i'll try and find time to do a 'beautified' version to show how you can build on apps like this.
Offline  
Old 05-23-2006, 10:20 AM   #10
jfisher
CrackBerry Addict
 
Join Date: Jun 2005
Location: Manchester, UK
Model: BOLD
Carrier: t-mobile
Posts: 714
Default

in response to itnwc's query about not being able to acess errors; i've found the most useful tool when debugging webservice code to be a decent packet sniffer, i always have smartsniff ( http://www.nirsoft.net/utils/smsniff.html ) running and it's saved me countless hours when trying to track down problems.
Offline  
Old 05-29-2006, 04:01 PM   #11
itnwc
New Member
 
Join Date: Apr 2006
Model: 7100
Posts: 7
Default

thanks jfisher, i use ksoap 1.2 now, and i use all the files from your example, but the result is the same, now my code is as following:
********************************************
package Server2BB_WebService.Server2BBService;

import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.system.*;

import java.util.*;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.io.*;
import javax.microedition.io.*;
import Server2BB_WebService.Server2BBService.MarshalAddr;
import org.ksoap.*;
import org.ksoap.ClassMap;
import org.ksoap.transport.*;


public class StockQuoteDemo extends UiApplication
{
public static void main (String[] args)
{
StockQuoteDemo theApp = new StockQuoteDemo ();
theApp.enterEventDispatcher ();
}

public StockQuoteDemo ()
{
pushScreen (new StockQuoteScreen ());
doSOAP();
}

final class StockQuoteScreen extends MainScreen //implements FieldChangeListener
{
LabelField resultItem;
BasicEditField symbolField;
ButtonField bf;

public StockQuoteScreen ()
{
LabelField title = new LabelField ("StockQuote Sample", LabelField.ELLIPSIS|LabelField.USE_ALL_WIDTH);
setTitle (title);

symbolField = new BasicEditField ("Stock Symbol ", "ORCL", 4, BasicEditField.EDITABLE|BasicEditField.FILTER_UPPE RCASE);
resultItem = new LabelField ("Stock Price", LabelField.ELLIPSIS|LabelField.USE_ALL_WIDTH);

bf = new ButtonField ("Get price", Field.FOCUSABLE);
//bf.setChangeListener (this);

add (symbolField);
add (resultItem);
add (bf);
}

public boolean onClose ()
{
Dialog.alert ("Goodbye!");
System.exit (0);
return true;
}
}
public void doSOAP()
{
try
{
ClassMap classMap = new ClassMap ();
classMap.addMapping ("http: ipadresse/Server2BB-WebService/Server2BBService", "SimpleClass", new SimpleClass().getClass());
SoapObject rpc = new SoapObject ("http: ipadresse/Server2BB-WebService/Server2BBService",
"getSimpleClass1");
rpc.addProperty("userstr","sam");
rpc.addProperty("conStr","sung");


HttpTransport ht = new HttpTransport ("http:ipadresse/Server2BB_WebService/Server2BBWebservice.asmx",
"http: ipadresse/Server2BB_WebService/Server2BBService/getSimpleClass1");
ht.setClassMap(classMap);
ht.debug = true;

SimpleClass sc = (SimpleClass) ht.call(rpc);
System.out.println(sc.i);
System.out.println(sc.str);
}

catch (Exception e)
{
e.printStackTrace ();
System.out.println(e.toString());

}
}
}
************************************************** *
/*
* SimpleClass.java
*
* xxx169; <your company here>, 2003-2005
* Confidential and proprietary.
*/

package Server2BB_WebService.Server2BBService;

import java.lang.*;
import java.util.Calendar;
import org.kobjects.serialization.*;


/**
*
*/
class SimpleClass implements KvmSerializable{
public String str;
public int i;
SimpleClass(){}
SimpleClass(String str,int i) {this.str = str; this.i = i; }

public Object getProperty (int index) {
switch (index) {
case 0: return str;
case 1: return new Integer (i);
default: throw new RuntimeException ();
}
}
public int getPropertyCount(){return 2;}
public void getPropertyInfo (int index, PropertyInfo info) {
switch (index) {
case 0:
info.name = "str";
info.type = Integer.class;
break;
case 1:
info.name = "i";
info.type = Integer.class;
break;
default:
throw new RuntimeException ();
}
}
public void setProperty (int index, Object value) {
switch (index) {
case 0: str = (String) value; break;
case 1: i = ((Integer) value).intValue (); break;
default: throw new RuntimeException ();
}
}
}
**************************************
and the exception is always:
SoapFault - faultcode: 'soap:Client' faultstring: 'System.Web.Services.Protocols.SoapException: Der Server konnte die Anforderung nicht lesen. ---> System.InvalidOperationException: Fehler im XML-Dokument (4,4). ---> System.InvalidOperationException: <getSimpleClass1 xmlns='http: ipaddress/Server2BB-WebService/Server2BBService'> wurde nicht erwartet.
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationReader1.Read9_getSimpleClass1()
at Microsoft.Xml.Serialization.GeneratedAssembly.getS impleClass1Serializer.Deserialize(XmlSerialization Reader reader)
at System.Xml.Serialization.XmlSerializer.Deserialize (XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
--- Ende der internen Ausnahmestapelxxx195;xxx188;berwachung ---
at System.Xml.Serialization.XmlSerializer.Deserialize (XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
at System.Xml.Serialization.XmlSerializer.Deserialize (XmlReader xmlReader, XmlDeserializationEvents events)
at System.Xml.Serialization.XmlSerializer.Deserialize (XmlReader xmlReader)
at System.Web.Services.Protocols.SoapServerProtocol.R eadParameters()
--- Ende der internen Ausnahmestapelxxx195;xxx188;berwachung ---
at System.Web.Services.Protocols.SoapServerProtocol.R eadParameters()
at System.Web.Services.Protocols.WebServiceHandler.In voke()
at System.Web.Services.Protocols.WebServiceHandler.Co reProcessRequest()' faultactor: 'null' detail: [EndTag </detail>]
************************************************** **
i saw many articles and checked the code again and again, but always not resolved it, so does anyone have idea to resolve this problem? any suggestion is helpful.

thanks in advance

itnwc
Offline  
Old 05-30-2006, 08:12 AM   #12
itnwc
New Member
 
Join Date: Apr 2006
Model: 7100
Posts: 7
Default

hi, i got it work, the world is so wonderful, when i see the output, great!
Offline  
Old 05-30-2006, 09:20 AM   #13
jfisher
CrackBerry Addict
 
Join Date: Jun 2005
Location: Manchester, UK
Model: BOLD
Carrier: t-mobile
Posts: 714
Default



Offline  
Old 05-30-2006, 09:24 AM   #14
simon.hain
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
Default

how did you solve your problem? (just in case sb wants to do some SOAP on his own...)
__________________
java developer, Devinto, hamburg/germany
Offline  
Old 05-30-2006, 11:35 AM   #15
everettwolf
New Member
 
Join Date: May 2006
Model: 7520
Posts: 4
Default

Hi itnwc,
I received your private email, and your code via FTP, but it looks as if you figured it out. Let me know if that's not the case.

jfisher, didn't look at your zip, but you mentioned a tutorial -- that would be great for future SOAP/Blackberry people!!! What a nightmare getting it to work initially (extremely easy from the JDE, but evil on the device directly). I'll try to help out if I can, but I'm on a tight deadline.

I think one thing that would be helpful to a lot of people is supplying the SOAP stuff WITHOUT jar files (in other words, working code, referenced properly, that will compile, etc.), because I'm pretty sure you have to modify the original code slightly (at least I did with SOAP 1.2) in order to get it to work the way you'd expect with .NET webservices and a Blackberry device.
Offline  
Old 05-30-2006, 12:30 PM   #16
everettwolf
New Member
 
Join Date: May 2006
Model: 7520
Posts: 4
Default

jfisher,
Just ran your code. Works great.

I want to make it specifically clear, however: all the sample SOAP stuff that ksoap.org, et. al., provide are extremely simple to get to work, including yours, but they are environment specific.

1) is Google's api a .NET webservice?
2) whether the .NET webservice follows the WDSL "standard" is not at issue, it's getting existing .NET webservices that work within the .NET framework to work within the KSoap world. There are several modifications you may need to make within either the webservice code or the ksoap code, or both. What are those modifications? What are their impact? There are plenty of responses in the newsgroups that say "of course" and "obviously" and "naturally" it will work with .NET webservices "if this" and "if that," but with no code to back it up. Granted, those changes can be extremely minor, but in a world where a misplaced semicolon will cause your app to not compile, compounded by an environment in which it is extremely difficult to debug, nothing short of sample code is all that helpful if you're under a time constraint.
3) There really aren't any standards, just accepted, albeit loose, rules, constantly changing.

For example, your call to the Google webservice using "urn:GoogleSearch" as a parameter is not really a "standard." If I were to create a .NET webservice using GoogleSearch as a paramater with the same suggested spelling functionality, tacking "urn:" at the beginning *might* make it fail. Simple, yes, but frustrating when you can't step through code (which you can't if you're importing JAR/ZIP/etc. files) to see where the problem lies.
Offline  
Old 06-20-2006, 08:12 AM   #17
vikas
New Member
 
Join Date: Jun 2006
Model: 7100T
Posts: 4
Default Error in Accessing google web service

I just went through the thread for how to write a web service client for accessing the web services using KSOAP.
As u have indicated --
1. I downloaded the googleapi folder and opened the project in the JDE.
I have the required key from the google to access the service.
2. It is build properly with some warnings.
3. While I run it on the emulator it asks for entering a string for contacting service to find correct spelling.
After I enter it gives the following error--

error in webservice: org.kxml.io.ParseException: unexpected: ParseEvent type=128 text='Unknown host api.google.com:80' @-1:-1

When I tried to find the root cause of the error then I found out that the error is due to the following line in HTTPTransport

responseEnvelope.parse (xp);

Can you help me in debugging this.

Plz do it asap as I have a deadline to meet.

Thanks in advance

Vikas
Offline  
Old 09-03-2007, 05:58 AM   #18
sudhirispl
New Member
 
Join Date: Aug 2007
Model: 8800
PIN: N/A
Carrier: Vodafone
Posts: 14
Default

Quote:
Originally Posted by jfisher View Post


i have used ksoap2-j2me-core-2.1.0.jar in my app for call .net web services.but i didn't get any output from web services.

my code is

import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.system.*;

import java.util.*;

import org.ksoap2.*;
import org.ksoap2.serialization.*;
import org.ksoap2.transport.*;

public class StockQuoteDemo extends UiApplication
{
public static void main (String[] args)
{
StockQuoteDemo theApp = new StockQuoteDemo ();
theApp.enterEventDispatcher ();
}

public StockQuoteDemo ()
{
pushScreen (new StockQuoteScreen ());
doSOAP();
}

final class StockQuoteScreen extends MainScreen
{
LabelField resultItem;
BasicEditField symbolField;
ButtonField bf;

public StockQuoteScreen ()
{
LabelField title = new LabelField ("StockQuote Sample", LabelField.ELLIPSIS|LabelField.USE_ALL_WIDTH);
setTitle (title);
symbolField = new BasicEditField ("Stock Symbol ", "ORCL", 4,BasicEditField.EDITABLE|BasicEditField.FILTER_UP PERCASE);
resultItem = new LabelField ("Stock Price", LabelField.ELLIPSIS|LabelField.USE_ALL_WIDTH);
bf = new ButtonField ("Get price", Field.FOCUSABLE);

add (symbolField);
add (resultItem);
add (bf);
}

public boolean onClose ()
{
Dialog.alert ("Goodbye!");
System.exit (0);
return true;
}
}
public void doSOAP()
{
try
{
System.out.println("i am here 1");

SoapObject rpc = new SoapObject ("test/HelloWorld", "test/HelloWorld");

//rpc.addProperty("userstr","itnwc");

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.bodyOut = rpc;
envelope.dotNet = true;
envelope.encodingStyle = SoapSerializationEnvelope.ENC;

HttpTransport ht = new HttpTransport ("http://192.168.15.107/WebSite/Service.asmx");
ht.debug = true;
System.out.println("i am here 2");
ht.call("test/HelloWorld",envelope);
System.out.println("i am here 3");
System.out.println("ok:" + envelope.toString());
System.out.println("Result of BB:" + envelope.getResult());

}

catch (Exception e)
{
System.out.println("i am here in catch");
e.printStackTrace ();

}
}
}
================================================
my output is

i am here 1
i am here 2


i am here in catch
No stack trace

what should do.plz reply the answer.thanks in advance

Last edited by sudhirispl; 09-03-2007 at 06:02 AM..
Offline  
Old 09-07-2007, 12:49 AM   #19
koedur
Knows Where the Search Button Is
 
Join Date: May 2007
Model: 8800
PIN: N/A
Carrier: Rogers
Posts: 17
Default

one useful thing to do is to see whether ksoap generated the proper soap envelope if an exception is thrown.

in your catch block, you could do something like:

System.err.println( ht.requestDump );
System.err.println( ht.responseDump );

this will print out the request and response envelopes to see the actual xml.
Offline  
Old 01-25-2008, 01:04 AM   #20
neelam.upreti
New Member
 
Join Date: Jan 2008
Model: NA
PIN: N/A
Carrier: NA
Posts: 3
Default Exception Thrown ------ > java.io.InterruptedIOException

Hi Friends,
I am building a sample application in Blackberry JDE 4.2 .
This application is just to access webservices that is uploaded on Bea Weblogic 8.1 server.For accesing webservice using ksoap2-j2me-core-2.1.2.jar.
I am using the following code to invoke webservice from my BB application.

<CODE>

try {
// build request string
System.out.println("Creating Soap Object");
SoapObject rpc = new SoapObject
("urn:PriceService", "getPrice");
System.out.println("adding to Price Property");
rpc.addProperty ("price", "DeviceId");

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(rpc);

HttpTransport transportSE = new HttpTransport("http://10.197.140.141:7001/priceservice_javaclass/PriceService");
transportSE.debug = true;
transportSE.call("uurn:PriceService#getPrice", envelope);
System.out.println("Called uurn:PriceService#getPrice by transportSE");

System.out.println("Res "+envelope.getResponse());

}
catch (Exception e) {
System.out.println("Exception Thrown ------ > "+e);
e.printStackTrace();
System.out.println(e.toString());

}



</CODE>


When I am testing this application on Simulator and build all and run the project , getting following error :-
Exception Thrown ------ > java.io.InterruptedIOException: Local connection timed out after ~ 120000

I am not able to understand whether it is the problem in the above code or in settings of simulator.

Thanks in advance
Offline  
Closed Thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


ITENA Total C-Ram 8gm Automix Dual Cure self Adhesive Resin Luting Dental Cement picture

ITENA Total C-Ram 8gm Automix Dual Cure self Adhesive Resin Luting Dental Cement

$56.99



Fanuc S-RAM Memory Module A20B-3900-0284/01A *New No Box* picture

Fanuc S-RAM Memory Module A20B-3900-0284/01A *New No Box*

$154.95



RAM MODULE (COMES WITH WIRING HARDNESS) picture

RAM MODULE (COMES WITH WIRING HARDNESS)

$200.00



37061 - IMPERIAL RAM MODULE -  picture

37061 - IMPERIAL RAM MODULE -

$210.00



Make Offer Oem Caterpillar 2613222 Mount Ram picture

Make Offer Oem Caterpillar 2613222 Mount Ram

$75.00



Double Acting Hollow Ram Cylinder (60 Tons - 2

Double Acting Hollow Ram Cylinder (60 Tons - 2") (YG-6050KS)

$549.00







Copyright © 2004-2016 BlackBerryForums.com.
The names RIM © and BlackBerry © are registered Trademarks of BlackBerry Inc.