我想在我的 android 应用中使用 soap 使用以下 Web 方法。谁能帮我?
I want to use the following web method from my android app using soap. Can anyone help me?
网络方法
public XmlElement findUserInfoById(int Id)
{
//string name = ""; string email = ""; string phone = "";
con.Open();
SqlCommand cmd = new SqlCommand("select*from tblUsers where Id ="+ Id, con);
cmd.ExecuteNonQuery();
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
con.Close();
XmlDataDocument xmldata = new XmlDataDocument(ds);
XmlElement xmlElement = xmldata.DocumentElement;
return xmlElement;
}
try {
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapObject response = (SoapObject) envelope.getResponse();
SoapObject s = (SoapObject) response.getProperty(0);
for (int i = 0;i<s.getPropertyCount();i++){
Object property = s.getProperty(i);
if(property instanceof SoapObject){
SoapObject category_list = (SoapObject) property;
String strName = category_list.getProperty("name").toString();
String strEmail = category_list.getProperty("email").toString();
String strPhone = category_list.getProperty("phone").toString();
Result = "Name : " + strName + "\nEmail : " + strEmail + "\nPhone : " + strPhone;
}
}
} catch (Exception e) {
e.printStackTrace();
}
网络方法
public XmlElement findUserInfoById(int Id)
{
//string name = ""; string email = ""; string phone = "";
con.Open();
SqlCommand cmd = new SqlCommand("select*from tblUsers where Id ="+ Id, con);
cmd.ExecuteNonQuery();
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
con.Close();
XmlDataDocument xmldata = new XmlDataDocument(ds);
XmlElement xmlElement = xmldata.DocumentElement;
return xmlElement;
}
try {
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapObject response = (SoapObject) envelope.getResponse();
SoapObject s = (SoapObject) response.getProperty(0);
for (int i = 0;i<s.getPropertyCount();i++){
Object property = s.getProperty(i);
if(property instanceof SoapObject){
SoapObject category_list = (SoapObject) property;
String strName = category_list.getProperty("name").toString();
String strEmail = category_list.getProperty("email").toString();
String strPhone = category_list.getProperty("phone").toString();
Result = "Name : " + strName + "\nEmail : " + strEmail + "\nPhone : " + strPhone;
}
}
} catch (Exception e) {
e.printStackTrace();
}