i have to pass
test@test.com test
to
Wsdl
http://myurl.com/Service.svc/Service.svc
Code Tried :
import android.os.AsyncTask; import android.os.Bundle; import android.util.Log; import android.widget.TextView; import android.app.Activity; import android.app.Dialog; import android.app.ProgressDialog; import android.content.DialogInterface; import android.content.DialogInterface.OnCancelListener; import java.io.Writer; import org.ksoap2.*; import org.ksoap2.serialization.*; import org.ksoap2.transport.*; import org.xmlpull.v1.XmlSerializer; public class MainActivity extends Activity { private static final String METHOD_NAME = "Service"; private static final String NAMESPACE = "http://tempuri.org/"; private static final String URL = "http://myurl.com/Service.svc"; final String SOAP_ACTION = "http://tempuri.org/ISilentManagerAPI/Service"; TextView tv; StringBuilder sb; private XmlSerializer writer; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); tv = new TextView(this); sb = new StringBuilder(); new testReq().execute(); tv.setText(sb.toString()); setContentView(tv); } class testReq extends AsyncTask { Dialog dialog; @Override protected void onPreExecute() { // TODO Auto-generated method stub super.onPreExecute(); dialog = ProgressDialog.show(MainActivity.this, "Please Wait...", "Testing........"); dialog.setCancelable(true); dialog.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { // TODO Auto-generated method stub cancel(true); } }); } @Override protected void onPostExecute(Void result) { // TODO Auto-generated method stub super.onPostExecute(result); dialog.dismiss(); } @Override protected Void doInBackground(Void... params) { // TODO Auto-generated method stub call(); return null; } } public void call() { try { SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); PropertyInfo req = new PropertyInfo(); req.name = "hello"; req.type = String.class; req.setValue("" + "test@test.com " + "test123 " + " "); request.addProperty(req); SoapSerializationEnvelope envelope = new SoapSerializationEnvelope( SoapEnvelope.VER11); envelope.dotNet = true; envelope.setOutputSoapObject(request); HttpTransportSE androidHttpTransport = new HttpTransportSE(URL); androidHttpTransport.call(SOAP_ACTION, envelope); SoapPrimitive result = (SoapPrimitive) envelope.getResponse(); String resultData = result.toString(); Log.i("Result", "" + resultData); sb.append(resultData + "\n"); } catch (Exception e) { sb.append("Error:\n" + e.getMessage() + "\n"); e.printStackTrace(); } } }
i am using internet permission in AndroidManifest.xml
and output will be like
any . . return data .
After Trying this code getting exception
LogCat
08-01 13:27:53.240: W/System.err(10915): java.io.IOException: HTTP request failed, HTTP status: 404 08-01 13:27:53.300: W/System.err(10915): at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:195) 08-01 13:27:54.370: W/System.err(10915): at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:116) 08-01 13:27:54.390: W/System.err(10915): at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:111) 08-01 13:27:54.410: W/System.err(10915): at com.example.testeset.MainActivity.call(MainActivity.java:105) 08-01 13:27:54.440: W/System.err(10915): at com.example.testeset.MainActivity$testReq.doInBackground(MainActivity.java:80) 08-01 13:27:54.460: W/System.err(10915): at com.example.testeset.MainActivity$testReq.doInBackground(MainActivity.java:1) 08-01 13:27:54.470: W/System.err(10915): at android.os.AsyncTask$2.call(AsyncTask.java:264) 08-01 13:27:54.480: W/System.err(10915): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305) 08-01 13:27:54.490: W/System.err(10915): at java.util.concurrent.FutureTask.run(FutureTask.java:137) 08-01 13:27:54.500: W/System.err(10915): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208) 08-01 13:27:54.500: W/System.err(10915): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076) 08-01 13:27:54.500: W/System.err(10915): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569) 08-01 13:27:54.500: W/System.err(10915): at java.lang.Thread.run(Thread.java:856)
Here i am getting Exception:
androidHttpTransport.call(SOAP_ACTION, envelope);