1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
| package com.carlos.wcf;
import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.Toast;
import org.ksoap2.serialization.SoapObject;
import java.util.HashMap;
public class MainActivity extends AppCompatActivity {
private Button b_get_WCFResult; private final static String TAG="WCFResult";
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);
b_get_WCFResult= (Button) findViewById(R.id.b_get_WCFResult);
b_get_WCFResult.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { getWCFResult(); } });
}
private void getWCFResult(){ HashMap<String,Object> map=new HashMap<>(); map.put("title", "提醒"); map.put("content", "晚上写篇博客"); WCFService.callWCFService("CreateNotice", map, new WCFService.WCFServiceCallBack() { public void callBack(SoapObject result) { if(result!=null){ Toast.makeText(MainActivity.this,result.toString(),Toast.LENGTH_SHORT).show(); Log.i(TAG, result.toString());
SoapObject soapObject=(SoapObject)result.getProperty("result"); Log.i(TAG,soapObject.toString()); if(soapObject.toString().equals("anyType{}")){ Log.i(TAG,"没有结果"); }else{ for(int i=0;i<soapObject.getPropertyCount();i++){ Log.i("WCFResult",soapObject.getProperty(i).toString()); } }
} } }); } }
|