View Single Post
Old 04-14-2009, 02:58 AM   #30 (permalink)
Drakhelm
New Member
 
Join Date: Apr 2009
Model: 8100
PIN: N/A
Carrier: Cincinnati Bell
Posts: 3
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default preVerify and attaching

Okay, well, I have a few questions of my own, but I figured I might post what I've learned.

First, you need to preverify the ksoap-core.jar (you can't preverify the ksoap-full.jar, it gives you an error.)

To do that, after you download the ksoap-core.jar you're going to use the command line (cmd.com/cmd.exe) to navigate to wherever you installed the JDE
then run

preverify -classpath <path to net_rim_api.jar> <path to ksoap2-j2me-core-*.jar>

this will give you an output folder in your bin directory (or probably whatever directory you run the preverify utility from (I'm not sure, I've just ran it from the bin directory of the JDE)

In the output folder will be a ksoap-whatever.jar file that is slightly bigger than the original .jar file.

You're going to (this is important) want to create a "lib" folder under the project folder that you want to attach the ksoap2 to.

Once you have that, what you want to do is create a new project

Once you have done that change the project type (project->properties->application tab) from the CDLC App to Library, and import the ksoap2.jar that was created when you ran the preverify (the one that you hopefully moved to the "lib" path under your project path.

Now, build that project, and you should get a ksoap2.cod file as output, which is fine, leave it alone.

Now, in your project (this should all have occurred in the same workspace) go to project->dependencies-> and specify that it is dependent on the ksoap2 project.

That should allow you to import the ksoap library.

(Though I do wonder if there's anyway to get the IDE to recognize the ksoap2 classes so it'll automatically give you the function definitions and class definitions)


Now, that handles the attaching of the files.

My questions are

1. Where do I get a MDS Simulator? (I checked the rim site, but I can't find an MDS Simulator anywhere.)

2. Can some one help me with this, on the device the following is throwing a
java.io.ioexception: Tunnel timed out

Code:
/*
 * ksoaptest.java
 *
 *  <your company here>, 2003-2008
 * Confidential and proprietary.
 */

package ;

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 net.rim.blackberry.api.invoke.*;
import java.util.*;
import java.lang.*;
import javax.microedition.pim.*;
import net.rim.device.api.i18n.*;
import net.rim.device.api.system.*;
import net.rim.device.api.util.*;
import org.ksoap2.*;
import org.ksoap2.serialization.*;
import org.ksoap2.transport.*;
import java.io.*;
import javax.microedition.io.*;
import net.rim.device.api.crypto.certificate.x509.*;


/**
 * 
 */
class ksoaptest extends net.rim.device.api.ui.UiApplication {
    ksoaptest() {            
        pushScreen(new kScreen());
    }
    
    public static void main(String args[]) {
        ksoaptest kst = new ksoaptest();
        kst.enterEventDispatcher();
    }
} 

class kScreen extends MainScreen {
    public LabelField lf_title;
    public RichTextField rf_results;
    public String results;
            
    public MenuItem mi_runtest = new MenuItem("Run SOAP Test",4390,10) {
        public void run() {
            RunTest();
        }
    };
    
    protected void makeMenu(Menu menu,int instance) {
        menu.add(mi_runtest);
        super.makeMenu(menu,0);
    }
    
    public kScreen() {
        lf_title = new LabelField("KSoap Test");        
        add(lf_title);
        
        rf_results = new RichTextField("Results");
        add(rf_results);
        
        results = "";        
        
    }        
    
    public void RunTest() {
        try {            
            System.out.println("Initializing Strings");
            String serviceNamespace = "h**p://w w w . exa mple. c o m/import/";
            String serviceURL = "h**p://w w w . exa mple. c o m/import/blackberry.wsdl";
            String serviceAction = "h**p://w w w . exa mple. c o m/import/blackberry.php";
            String serviceMethod = "HelloWorld";
            System.out.println("Strings Initialized, Instantiating Variables");
        
            SoapObject request = new SoapObject(serviceNamespace,serviceMethod);
            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
            envelope.bodyOut = request;
            HttpTransport ht = new HttpTransport(serviceURL);
            System.out.println("Variables Instantiated, making HTTP Call");
            ht.call(serviceAction,envelope);            
            System.out.println("About to display results.");
            results = (String)envelope.getResponse();
        }
        catch(Exception exception) {
            System.out.println("EXCEPTION EXCEPTION EXCEPTION (Exception Thrown)");
            results = exception.toString();
        }
        rf_results.setText(results);
    }
    
}
Thank you for your time.
Offline   Reply With Quote