我有 android 代码,它有两个从 HashMap Key , value 获取的整数变量。
我试图将这两个变量传递给 SOAP Web 服务,但什么也没发生。
注释 1:我确定我的 WebService 代码正在工作并将正确的数据输入到数据库中,我已经对其进行了测试。
注 2:FROM 调试显示“SID”和“状态”具有正确的值。
但是将这些值发送到 SOAP 的问题。
android Activity 中的完整 SOAP 代码:
sumbit.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
for (Map.Entry<Integer, Integer> mapEntry : checkBoxState
.entrySet()) {
int SID = mapEntry.getKey();
int status = mapEntry.getValue();
Toast.makeText(context,
String.valueOf(SID) + String.valueOf(status),
Toast.LENGTH_SHORT).show();
try {
SoapObject request = new SoapObject(NAMESPACE,
METHOD_NAME);
HttpTransportSE androidHttpTransport = new HttpTransportSE(
URL);
PropertyInfo pi = new PropertyInfo();
pi.setName("SID");
pi.setValue(SID);
pi.setType(Integer.class);
request.addProperty(pi);
PropertyInfo pi2 = new PropertyInfo();
pi2.setName("status");
pi2.setValue(status);
pi2.setType(Integer.class);
request.addProperty(pi2);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
androidHttpTransport.call(SOAP_ACTION, envelope);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (XmlPullParserException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
完整的网络服务方法代码:
public void insertApsentData(int SID , int status ) throws SQLException, ClassNotFoundException, ReflectiveOperationException, Throwable{
// Make new Connection to database .
Dbconnection NewConnect = new Dbconnection();
Connection con = NewConnect.MakeConnect();
Statement stmt = con.createStatement();
// this i'm usre is working fine
stmt.executeUpdate("INSERT INTO apsent SET course_id=1, teacher_id= 1 , class_id= 3 , interval_id= 5 , day_id = 1 , APSSENT_DATE = CURdate() ,state = " + status + ", student_id = " + SID +" ,school_id = 1;");//called the procedure
}