我的应用程序是移动购物助手。我已经尝试了一些代码,但它不起作用。我想将数据从php发送到Android。每次在列表中添加新项目(在php中)时,必须在Android中同步。我的示例代码:
public void onClick(View arg0) {
tbnum=txtproduct.getText().toString();
final SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("id", mid);
request.addProperty("tbnum", tbnum);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.debug=true;
try {
androidHttpTransport.call(SOAP_ACTION, envelope);
System.out.println("response: " + androidHttpTransport.responseDump);
SoapObject result = (SoapObject)envelope.getResponse();
//SoapObject result = (SoapObject) envelope.getResponse();
if(result!=null){
//String strRes = result.toString();
Toast.makeText(getApplicationContext(),"item has been received", Toast.LENGTH_LONG).show();
}
else {
Toast.makeText(getApplicationContext(),
"Web Service not Response!", Toast.LENGTH_LONG).show();
}
答案 0 :(得分:0)