package com.example.test; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.MalformedURLException; import java.net.*; import android.os.AsyncTask; import android.os.Bundle; import android.app.Activity; import android.util.Log; import android.widget.TextView; import android.widget.Toast; import org.ksoap2.SoapEnvelope; import org.ksoap2.serialization.PropertyInfo; import org.ksoap2.serialization.SoapObject; import org.ksoap2.serialization.SoapSerializationEnvelope; import org.ksoap2.serialization.SoapPrimitive; import org.ksoap2.transport.AndroidHttpTransport; import org.ksoap2.transport.HttpTransportSE; public class MainActivity extends Activity { /** Called when the activity is first created. */ private static String SOAP_ACTION = "http://tempuri.org/HelloWorld"; private static String NAMESPACE = "http://tempuri.org/"; private static String METHOD_NAME = "HelloWorld"; private static String URL = "http://117.227.58.74/vehicle//WebService.asmx"; String weight = "77"; String fromUnit = "78"; TextView tv; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //tv =(TextView)findViewById(R.id.textView1); SoapObject Request = new SoapObject(NAMESPACE, METHOD_NAME); PropertyInfo weightProp =new PropertyInfo(); weightProp.setName("lat"); weightProp.setValue(weight); weightProp.setType(double.class); Request.addProperty(weightProp); PropertyInfo fromProp =new PropertyInfo(); fromProp.setName("log"); fromProp.setValue(fromUnit); fromProp.setType(double.class); Request.addProperty(fromProp); SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); soapEnvelope.dotNet = true; soapEnvelope.setOutputSoapObject(Request); Toast.makeText(getBaseContext(),"1",Toast.LENGTH_LONG).show(); HttpTransportSE aht = new HttpTransportSE(URL); try { Toast.makeText(getBaseContext(),"2",Toast.LENGTH_LONG).show(); aht.call(SOAP_ACTION, soapEnvelope); Toast.makeText(getBaseContext(),"3",Toast.LENGTH_LONG).show(); SoapPrimitive resultString = (SoapPrimitive)soapEnvelope.getResponse(); Toast.makeText(getBaseContext(),"4",Toast.LENGTH_LONG).show(); //Log.i("myApp", response.toString()); //tv.setText("Status:" + resultString); } catch (Exception e) { e.printStackTrace(); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)