当我发送用户名和密码时,它发送给我一个错误:publicKey 和用户名和密码未连接网络服务,我不知道 http://mobilews.terra.net.lb/MobileService是否有任何问题.asmx?op=authenticateLogin 用户名是 :mabyad 密码是 :dori
MainActivity.java 代码
package com.kak;
import android.os.Bundle;
import android.os.StrictMode;
import com.kak.R;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
//import android.widget.Toast;
//import android.view.View.OnClickListener;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.transport.HttpTransportSE;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.serialization.SoapPrimitive;
//import android.widget.TextView;
//import android.app.ProgressDialog;
//import android.os.AsyncTask;
public class MainActivity extends Activity {
private final static String SOAP_NAMESPACE = "http://mobilews.terra.net.lb";
private static final String SOAP_URL = "http://mobilews.terra.net.lb/MobileService.asmx";
private static final String SOAP_ACTION = "http://tempuri.org/authenticateLogin";
private static final String SOAP_METHOD_NAME = "authenticateLogin";
//private PropertyInfo pi1;
Button button1;
EditText UserName;
EditText Password;
public String publicKey;
String tv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
StrictMode.ThreadPolicy policy =
new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
setContentView(R.layout.activity_main);
button1=(Button)findViewById(R.id.button1);
button1.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
UserName=(EditText)findViewById(R.id.UserName);
Password = (EditText)findViewById(R.id.Password);
SoapObject request = new SoapObject(SOAP_NAMESPACE, SOAP_METHOD_NAME);
request.addProperty("userName", UserName.getText().toString());
request.addProperty("password",Password.getText().toString());
request.addProperty("publicKey", String.valueOf("Terr@Net$M0bilePK54"));
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
envelope.dotNet = true;
HttpTransportSE androidHttpTransport = new HttpTransportSE(SOAP_URL);
try{
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapPrimitive resultString = (SoapPrimitive)envelope.getResponse();
![android manifest Permissions][1]
SoapPrimitive resultInteger =(SoapPrimitive)envelope.getResponse();
tv=resultInteger.toString();
if (resultString!=null || resultInteger !=null) {
Toast.makeText(getBaseContext(),tv,
Toast.LENGTH_LONG).show();
}
else {
Toast.makeText(getBaseContext(),"wrong",
Toast.LENGTH_LONG).show();
}
}catch (Exception e) {
e.printStackTrace();
}
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}