BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 02-18-2009, 03:55 PM   #1 (permalink)
New Member
 
Join Date: Jan 2009
Model: 8330
PIN: N/A
Carrier: Bell
Posts: 3
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default KSOAP2 Issue

Please Login to Remove!

Hello,

I'm hoping someone can shed some light as to what I'm doing wrong. I currently have a Blackberry application that communicates with a web service I created. I am using HTTP POST as the communication method, and all works well.

However, I would like to try and pass complex object types, and have read in some post to try and use KSoap2, which I did.

I've referred to multiple discussions and have done the following. I preverified the KSOAP2 jar file, I added it as a dependency to my project. The code builds with no issues in the Blackberry JDE (4.2.0.98).

Everything seems fine, however I always receive the following exception in code which I cannot catch in a try statement:
"Uncaught Exception: Cannot find class ksoap.*", pretty much this message appears multiple times for various ksoap classes.

Code snippet:
Code:
public boolean ValidateLoginTokenKSOAP(LoginToken token){
        
        SoapObject rpc;
        SoapSerializationEnvelope env;
        HttpTransport ht;
        
        boolean blnValid = false;
        String urlRequest;
        String result;
        
        try
        {
          
            //serviceUrl = "xxxx://172.20.8.221/ACRWebService/ACRService.asmx";
            serviceNamespace = "xxxx://tempuri.org/";
            soapAction = "xxxx://tempuri.org/ValidateLoginCredentials";
            serviceMethod = "ValidateLoginToken";
            
            rpc = new SoapObject(serviceNamespace, serviceMethod);       
            rpc.addProperty("token", token);            
                 
            env = new SoapSerializationEnvelope(SoapEnvelope.VER11);
            
            env.bodyOut = rpc;
            env.dotNet = true;
            env.encodingStyle = SoapSerializationEnvelope.ENC;
            
            ht = new HttpTransport(serviceUrl);
            ht.debug = true;
            ht.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); 
                        
            result = null;
            
            blnValid = true;
            try
            {
                Object resp = null;
                System.out.println("Call for ht");
                ht.call(soapAction, env);
                resp = env.getResult();    
                System.out.println("Success!!");
            }
            catch(org.xmlpull.v1.XmlPullParserException ex2)
            {
                blnValid = false;
                String bah = ex2.toString();
                System.out.println(bah);
            }
            catch(Exception e)
            {
                blnValid = false;
                String bah = e.toString();
                System.out.println(bah);
            }
            
        }
        catch(Exception e)
        {            
            blnValid = false;
        }
        
        return blnValid;
    }
The exception always get's thrown on ht.call(soapAction, env);

Any help would be appreciated, I'm stumped on this. I know the reason is the library cannot be found on the simulator, but not sure how to fix it.

Last edited by littleb1980 : 02-18-2009 at 03:59 PM. Reason: Added Code Snippet
Offline  
Old 02-19-2009, 03:02 AM   #2 (permalink)
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

add the cod file of the ksoap library to the simulator directory
__________________
java developer, Devinto, hamburg/germany
Offline  
Old 02-19-2009, 08:50 AM   #3 (permalink)
New Member
 
Join Date: Jan 2009
Model: 8330
PIN: N/A
Carrier: Bell
Posts: 3
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I copied the KSoap.cod file to both these directories...

1. C:\Program Files\Research In Motion\BlackBerry Device Simulators 4.2.2\4.2.2.163 (8310-Rogers)
2. C:\Program Files\Research In Motion\BlackBerry Device Simulators 4.2.2\4.2.2.163 (8310-Rogers)\Java

They both contain other .cod files for the simulator I'm using. However, still receiving the error message.

Should I try and convert ksoap2-j2me-core-prev-2.1.2.jar which contains the classes directly to a .cod file. Right now the .cod I copied over is simply the one generated from my JDE application, which contains the ksoap2 jar file. If so, any utilities to convert a jar to .cod file easily readily available?

Thanks
Offline  
Old 02-19-2009, 01:57 PM   #4 (permalink)
New Member
 
Join Date: Jan 2009
Model: 8330
PIN: N/A
Carrier: Bell
Posts: 3
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I found the solution, when you preverify the .jar file, the verified copy is put in
C:\Program Files\Research In Motion\BlackBerry JDE 4.2.0\bin\output. I was using the jar that a preverified and not realizing that a verified one is created.



Hope this helps anyone else who encounters this problem.
Offline  




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