我正在尝试将带有nom,prenom和mail的对象“Personne”从带有soap的android中插入到数据库中。在我的logcat中没有错误。我的手机中有202状态请求失败。
这是我的logcat中的消息:
下面是我的代码:
public class MainActivity extends Activity implements View.OnClickListener{
private static final String SOAP_ACTION = "http://ws.projet.ma/create";
private static final String METHOD_NAME = "create";
private static final String NAMESPACE = "http://ws.projet.ma/";
private static final String URL = "http://ip@:8080/WebService/NewWebService?WSDL";
EditText nom;
EditText prenom;
EditText mail;
Button b;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
nom=(EditText)findViewById(R.id.textView);
prenom=(EditText)findViewById(R.id.textView2);
mail=(EditText) findViewById(R.id.textView3);
b=(Button)findViewById(R.id.button);
b.setOnClickListener(this);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
public void onClick(View v) {
if (v == b) {
try {
if (android.os.Build.VERSION.SDK_INT > 9) {
StrictMode.ThreadPolicy policy = new
StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
}
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
//PropertyInfo PI = new PropertyInfo();
Toast.makeText(this, "ok", Toast.LENGTH_SHORT).show();
if(nom.getText().toString() != "" && prenom.getText().toString() !="" &&
mail.getText().toString() !="") {
Toast.makeText(this, "bien", Toast.LENGTH_SHORT).show();
request.addProperty("create",
new Personne (nom.getText().toString(), prenom.getText().toString(),
mail.getText().toString() ));
Toast.makeText(this, "bien", Toast.LENGTH_SHORT).show();
}
SoapSerializationEnvelope envelope = new
SoapSerializationEnvelope(SoapEnvelope.VER11);
// envelope.dotNet = false;
envelope.setOutputSoapObject(request);
envelope.encodingStyle = SoapSerializationEnvelope.XSD;
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapPrimitive result = (SoapPrimitive) envelope.getResponse();
} catch (IOException e) {
Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
} catch (XmlPullParserException e) {
Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
}
}
}