6
任何人都可以建議「如何使用KSOAP2從Android調用PHP Web服務?」提供如何使用KSOAP2從Android調用PHP Webservice?
任何人都可以建議「如何使用KSOAP2從Android調用PHP Web服務?」提供如何使用KSOAP2從Android調用PHP Webservice?
示例代碼,現在你自己嘗試:)
private final String SOAP_ACTION = "urn:abc#login";
private final String METHOD_NAME = "UserLogin";
private final String NAMESPACE = "urn:abcwsdl";
private final String URL = "http://abc.com/service/server.php";
public void login()
{
SoapObject userRequest=new SoapObject(NAMESPACE, METHOD_NAME);
userRequest.addProperty("email", email); // login-account
userRequest.addProperty("password", password); // login-password
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("UserLogin", userRequest); // login-account
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.bodyOut = request;
HttpTransportAndroid androidHttpTransport = new HttpTransportAndroid(URL);
try {
Object result=envelope.getResult();
res=new DalLogin();
SoapObject resp=(SoapObject) result;
if(((SoapObject)result).getProperty("result").equals("error"))
{
res.setError_string("error");
res.setResult(resp.getProperty("response").toString());
}else
{
res.setError_string(null);
res.setUser_id(resp.getProperty("user_id").toString());
res.setSession_id(resp.getProperty("session_id").toString());
}
} catch (Exception aE) {
aE.printStackTrace();
}
}
歐麥爾u能請給我你的一些電子郵件地址,因爲我需要在Android網絡服務您的幫助。請 – Shah 2011-05-10 11:21:14
謝謝@UMAR ... 有沒有關於KSOAP2的完整文檔? – 2014-03-13 06:38:50
https://code.google.com/p/ksoap2-android/w/list – UMAR 2014-03-17 14:21:53