Código:
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
DEPENDENCIAS build.gradle
Código:
dependencies {
compile 'com.android.support:appcompat-v7:+'
compile files('libs/android-support-v4.jar')
compile files('libs/ksoap2-android-assembly-3.0.0.jar')
}
METODO
Código:
public void onClickB(View v) {
final String NAMESPACE = "http://suarpe.com/";
final String URL= "http://jhonnybmx-001-site1.smarterasp.net/ServicioClientes.asmx";
final String METHOD_NAME = "CustomerSearch";
final String SOAP_ACTION = "http://suarpe.com/CustomerSearch";
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
EditText txtID= (EditText) findViewById(R.id.searchtxt);
request.addProperty("ID", txtID.getText().toString());
SoapSerializationEnvelope envelope =
new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE transporte = new HttpTransportSE(URL);
try
{
transporte.call(SOAP_ACTION, envelope);
SoapPrimitive resultado_xml =(SoapPrimitive)envelope.getResponse();
String res = resultado_xml.toString();
TextView salida = (TextView) findViewById(R.id.txtsalida);
salida.setText(res);
}
catch (Exception e)
{
Toast.makeText(getBaseContext(),e.toString(), Toast.LENGTH_LONG).show();
}
}
ERROR
01-22 14:05:01.801 5174-5174/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.example.quore3, PID: 5174
java.lang.IllegalStateException: Could not execute method of the activity
at android.view.View$1.onClick(View.java:3823)
at android.view.View.performClick(View.java:4438)
at android.view.View$PerformClick.run(View.java:18422 )
at android.os.Handler.handleCallback(Handler.java:733 )
at android.os.Handler.dispatchMessage(Handler.java:95 )
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.jav a:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCa ller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit .java:595)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at android.view.View$1.onClick(View.java:3818)
************at android.view.View.performClick(View.java:4438)
************at android.view.View$PerformClick.run(View.java:18422 )
************at android.os.Handler.handleCallback(Handler.java:733 )
************at android.os.Handler.dispatchMessage(Handler.java:95 )
************at android.os.Looper.loop(Looper.java:136)
************at android.app.ActivityThread.main(ActivityThread.jav a:5017)
************at java.lang.reflect.Method.invokeNative(Native Method)
************at java.lang.reflect.Method.invoke(Method.java:515)
************at com.android.internal.os.ZygoteInit$MethodAndArgsCa ller.run(ZygoteInit.java:779)
************at com.android.internal.os.ZygoteInit.main(ZygoteInit .java:595)
************at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NoClassDefFoundError: org.ksoap2.serialization.SoapObject
at com.example.quore3.MainActivity.onClickB(MainActiv ity.java:52)
************at java.lang.reflect.Method.invokeNative(Native Method)
************at java.lang.reflect.Method.invoke(Method.java:515)
************at android.view.View$1.onClick(View.java:3818)
************at android.view.View.performClick(View.java:4438)
************at android.view.View$PerformClick.run(View.java:18422 )
************at android.os.Handler.handleCallback(Handler.java:733 )
************at android.os.Handler.dispatchMessage(Handler.java:95 )
************at android.os.Looper.loop(Looper.java:136)
************at android.app.ActivityThread.main(ActivityThread.jav a:5017)
************at java.lang.reflect.Method.invokeNative(Native Method)
************at java.lang.reflect.Method.invoke(Method.java:515)
************at com.android.internal.os.ZygoteInit$MethodAndArgsCa ller.run(ZygoteInit.java:779)
************at com.android.internal.os.ZygoteInit.main(ZygoteInit .java:595)
************at dalvik.system.NativeStart.main(Native Method)