android ksoap用法

	private static final String SERVICENAMESPACE = "http://api.yicheng120.com/soap/server.php/";
	 private static final String WEBSERVICEURL = "http://api.yicheng120.com/soap/server";
	 /* 登陆 */
	 public void login(String userName, String password) {
	  final String WS_METHOD_NAME = "login";
	  // 设置请求参数
	  SoapObject requestEnvelopeBody = new SoapObject(SERVICENAMESPACE,
	    WS_METHOD_NAME);
	  String md5password = MD5(password);
	  requestEnvelopeBody.addProperty("userName", userName);
	  requestEnvelopeBody.addProperty("password", md5password);
	  requestEnvelopeBody.addProperty("x_auth_mode", "mobile");
	  
	  // 请求
	  SoapObject result = soapRequest(WEBSERVICEURL,requestEnvelopeBody,SERVICENAMESPACE, WS_METHOD_NAME);
	  if (null == result) {
	   return;
	  }
	  
	  // 解析
	  String testStr;
	  testStr= result.toString();
	  SoapObject ycReturn=(SoapObject) result.getProperty("return");
	  
	  YiChengAPI.auth_token = ycReturn.getProperty("auth_token").toString();
	   }
	 
	 /* soap请求 */
	 protected SoapObject soapRequest(String WEBSERVICEURL,SoapObject requestEnvelopeBody,String SERVICENAMESPACE,
	   String WS_METHOD_NAME) {
	  // 设置envelope
	  SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
	    SoapEnvelope.VER11);
	  envelope.bodyOut = requestEnvelopeBody;
	  envelope.dotNet = false;
	  //envelope.setOutputSoapObject(requestEnvelopeBody);
	  // 请求服务器
	  HttpTransportSE transport = new HttpTransportSE(WEBSERVICEURL);  
	  transport.debug = true;
	  SoapObject result = null;
	  try {
	   transport.call(SERVICENAMESPACE + WS_METHOD_NAME, envelope);
	   //取回响应数据
	   result =(SoapObject) envelope.bodyIn;
	  }catch (IOException e) {
	   e.printStackTrace();
	  } catch (XmlPullParserException e) {
	   e.printStackTrace();
	  }
	  return result;
	 } 

我的话费充值店-各种面额

电信100元仅售98.60 
联通100仅售99.00
移动100仅售99.30

 

你可能感兴趣的:(android)