Note that there are some explanatory texts on larger screens.

plurals
  1. POCalling .NET web service from android with KSOAP2
    text
    copied!<p>I tried to call a .NET web service with KSOAP2 and it throws an exception at <code>androidHttpTransport.call(SOAP_ACTION, envelope)</code> and thus <code>return result="m"</code>. </p> <p>What should I do so that it will call the function?</p> <p>Here is my code:</p> <pre><code>public class LoginActivity extends Activity { private static final String NAMESPACE = "http://tempuri.org/" ; private static final String METHOD_NAME = "login"; private static final String SOAP_ACTION = NAMESPACE + METHOD_NAME; private static final String URL = "http://192.168.8.2/CompiledWebSite/WebService.asmx"; private EditText et_id,et_pwd; private Button btn_login; public String login(String str_id, String str_pwd){ String result ="a"; SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); request.addProperty("s_id", str_id); request.addProperty("pw", str_pwd); SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); envelope.dotNet = true; envelope.setOutputSoapObject(request); HttpTransportSE androidHttpTransport = new HttpTransportSE(URL); try { androidHttpTransport.call(SOAP_ACTION, envelope); SoapPrimitive Result = (SoapPrimitive)envelope.getResponse(); result = Result.toString(); } catch(Exception e) { result="m"; } return result; } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); btn_login = (Button) findViewById(R.id.BnLogin); et_id = (EditText) findViewById(R.id.ETStudentID); et_pwd = (EditText) findViewById(R.id.ETPassword); btn_login.setOnClickListener(new Button.OnClickListener() { public void onClick(View v){ String str_id, str_pwd; str_id = et_id.getText().toString(); str_pwd = et_pwd.getText().toString(); if (login(str_id,str_pwd)=="true"){ Toast toast=Toast.makeText(LoginActivity.this, str_id, 500); toast.setGravity(1, 1, 1); toast.show(); }else{ Toast toast=Toast.makeText(LoginActivity.this, login(str_id,str_pwd), 500); toast.setGravity(1, 1, 1); toast.show(); } } }); } } </code></pre> <p>Thanks!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload