I want to create a webservice client in my android application but i m getting VerifyError when i m try to run it.
Please have a look on the attached image.
Thanks
Zahid Naqvi
zahidalinaqvi@gmail.com
Using java Syntax Highlighting
- package a.t.m;
- import java.util.Vector;
- import org.ksoap2.SoapEnvelope;
- import org.ksoap2.serialization.SoapObject;
- import org.ksoap2.serialization.SoapSerializationEnvelope;
- import org.ksoap2.transport.HttpTransport;
- import android.app.Activity;
- import android.os.Bundle;
- import android.widget.TextView;
- public class First extends Activity {
- private static final String SOAP_ACTION = "http://tempuri.org/LocateSameAddress";
- private static final String METHOD_NAME = "LocateSameAddress";
- private static final String NAMESPACE = "http://tempuri.org/";
- // !!!!! IMPORTANT!!!!! THE URL OF THE CoLDFUSION WEBSERVER NOT LOCALHOST BECAUSE LOCALHOST IS THE ANDROID EMULATOR !!!!!
- private static final String URL = "http://74.54.60.18:2226/service.asmx?WSDL";
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
- setContentView(R.layout.main);
- //CALL the web service method with the two parameters vname and nname
- SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
- request.addProperty("LATITUDE", "44.7959");
- request.addProperty("LONGITUDE", "=-91.4435");
- request.addProperty("mile", "5");
- request.addProperty("Type", "AT");
- SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
- envelope.setOutputSoapObject(request);
- HttpTransport androidHttpTransport = new HttpTransport (URL);
- try {
- androidHttpTransport.call(SOAP_ACTION, envelope);
- // Get the SAOP Envelope back and the extract the body
- SoapObject resultsRequestSOAP = (SoapObject) envelope.bodyIn;
- /* Vector XXXX = (Vector) resultsRequestSOAP.getProperty("getMessageReturn");
- //Count of the arrays beneath starting from 0
- //You can see the buildup with the php site with nusoap http://localhost/DA/nusoapclient_test2.php
- int testat = XXXX.size();
- // It depends on how many arrays we have we can get to the attributs of one of them with get(0), get(1) ....
- SoapObject test = (SoapObject) XXXX.get(0);
- //Get the attributes in the array
- String tem = (String) test.getProperty("LATITUDE");
- tem = tem + " " + (String) test.getProperty("LONGITUDE");
- tem = tem + " " + (String) test.getProperty("mile");
- tem = tem + " " + (String) test.getProperty("Type");*/
- //Just show it in a text area field called lblStatus
- ((TextView)findViewById(R.id.lblStatus)).setText(resultsRequestSOAP.toString());
- // with androidhttptransport you need a catch block
- } catch(Exception E) {
- ((TextView)findViewById(R.id.lblStatus)).setText("ERROR:" + E.getClass().getName() + ": " + E.getMessage());
- }
- }
- }
Parsed in 0.038 seconds, using GeSHi 1.0.8.4


