I'll send you later my paypal account so you can deposit there my 25 dlls. Better yet, buy me a couple of psn card and send me the codes over a private message. That'd work better
I have been working with KSOAP2 and BB for quite a while, and they wokr perfectly, here is what you need
You only need this 3 imports to work well
Code:
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.*;
import org.ksoap2.transport.HttpTransport;
And you'll be having this variables
Code:
private SoapObject table = null; // Its the table of a DataSet
private SoapObject client = null; // Its the client pettition to the web service
private SoapObject tableRow = null; // Gets the information of a row from the table DataSet
private SoapObject responseBody = null; // Its the whole response of the WebService
private HttpTransport transport = null; // Its whta is used to make the call to the WebService
private SoapSerializationEnvelope sse = null; // Contains the information of the request and the response of the webservice
Now, i'll put how things work for 2 cases. 1, when asking for a DataSet with multiple tables and multiples rows each table. 2, when asking for a single response, like a integer or a boolean response
Lets firts start up our webServices our variables
Code:
sse = new SoapSerializationEnvelope(SoapEnvelope.VER11); // SOAP version is indicated here. Version 11 works nice
sse.addMapping(<WebService NameSpace>, <Name of the Class using it>, this.getClass());
sse.dotNet = true; // We stablish we sill be working with .NET webservices
transport = new HttpTransport(<URL of the webservices>);
transport.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
transporte.debug = debug; // Set it to either use transport.dumpRequest or dumpReponse to see the xml of the webservice request of response
Now, lets see the example of requesting the information and the webservices gives us a DataSet with 2 tables
Code:
// Here we set who are we gonna call, give the method arguments and do the call
client = new SoapObject(<WebServiceNameSpace>, <WebService Method Name we want to reuqest>);
// You can add as many properties as many as you need. I'd say that you set your webservices method to recieve only strings and do the convertions on you webservice. Its quite hard work with primitive values
client.addProperty(<agument name as String>, <argument Value>);
sse.setOutputSoapObject(client);
sse.bodyOut = client;
transporte.call(<WebService direct url>, sse);
Once we did the call for the WebService, we'll work on the reponse of this one
Code:
// We'll get the whole XML reponse with all the information
responseBody = (SoapObject) sse.getResponse();
// Now, the reponse works as a Vector. On position 0 we have the information of the Reponse while in position 1 we get the info we requested. So we get rid of the information reponse and lets grab the info we requested
responseBody = (SoapObject) responseBody.getProperty(1);
// And now, we have the n tables the WebService returned to us with the information, but still we can't access the info, so we'll get one of the tables separated. We'll use a very different variable for not to lose the whole info the webservice sended us. Once again, the tables are contained on a Vector. Lets grab the first one
table = (SoapObject) responseBody.getProperty(0);
// Now we have the table, but still can't use the info, soooo, lets grab a row individually
tableRow = (SoapObject) table.getProperty(0);
And there you have it, you can now access to the info of the table. How so? easy, just like this
Code:
tableRow.getProperty(<ColumnName>).toString()
Easy right, that's it for grabing the info of a DataSet with one or more tables. Now, lets see how single responses work, like integers or booleans, the only thing, different from the example before, you'll need to do, is, instead of saving the SoapSerializationEnvelope reponse on a SoapObject, juts grab the SSE reponse like this
If i want to check that a WebService returned me a "true" when this one return boolean values, i do this
Code:
sse.getResponse().toString().equals("true")
Yeah, i convert the response to string, easy to handle and convert to other types.
Its not much of a hassle to work with KSOAP2, i have found it easy to work with and pretty clean. Of course, JSR172 is cleaner and easier, but i coulnd't bring myself to make JSR-172 to work on several BB and decided to use this.
Hope this minitut worked, any question just post them here, and i'll be waiting for my PSN card codes.
Just as a last note, this is the library i'm using of KSOAP2
ksoap2-j2me-core-2.1.2.jar
And i have been developing on Java ME Platform SDK 3.0 Early Access. i'm having some troubles using this library on BlackBerry JDE. Had to make the jump cuz my boss want me to use direct BlackBerry API and not J2ME