public
Boolean SoapRequestWeb()
{
String nameSpace =ConfigCommon.getNetConfigProperties().getProperty(
"nameSpace"
);
//WebServices命名空間
String serviceURL = ConfigCommon.getNetConfigProperties().getProperty(
"serviceURL"
);;
//請求地址
String methodName =
"Login"
;
//方法名
SoapObject request =
new
SoapObject(nameSpace, methodName);
//聲明SOAP對象
//請求參數
request.addProperty(
"DeviceID"
,iemi);
request.addProperty(
"phone"
,phone);
SoapSerializationEnvelope envelope =
new
SoapSerializationEnvelope(SoapEnvelope.VER11);
//生成調用Webservice方法的SOAP請求信息
envelope.bodyOut = request;
envelope.dotNet=
true
;
//指定是否爲.NET版本
//建立HttpTransportSE對象。經過HttpTransportSE類的構造方法能夠指定WebService的WSDL文檔的URL
HttpTransportSE ht =
new
HttpTransportSE(serviceURL);
ht.debug =
true
;
String result=
""
;
try
{
ht.call(soapAction, envelope);
//使用call方法調用WebService方法,請求WebServices
if
(envelope.getResponse() !=
null
) {
result= envelope.getResponse().toString();
//獲取輸出結果
if
(result.isEmpty() || result.equals(
"null"
))
{
// Toast.makeText(this,"不存在該用戶,請重試!",Toast.LENGTH_LONG).show();
//Message("不存在該賬號,請確保手機號正確");
return
false
;
}
//使用Json對象對獲取的數據進行解析。
JSONObject jsonObj=
new
JSONObject(result);
String name=jsonObj.getString(
"UserName"
);
//保存當前登錄用戶
T_Users tu=
new
T_Users();
tu.setUserName(name);
if
(!name.isEmpty())
{
//保存好信息
// setContentView(R.layout.index);
return
true
;
}
else
{
Toast.makeText(
this
,result.toString(),Toast.LENGTH_LONG).show();
return
false
;
}
}
else
{
return
false
;
}
}
catch
(Exception e) {
e.printStackTrace();
Toast.makeText(
this
, e.getMessage(),Toast.LENGTH_LONG).show();
return
false
;
}
}