爲什麼我無法從Web服務獲取結果?當我調試代碼時,它顯示一個異常。無法從Web服務檢索結果
以下代碼用於Web服務請求。
@SuppressWarnings("deprecation")
protected boolean UserNameAvailability(final String sUserName)
{
boolean result = false;
SoapObject request = new SoapObject(getResources().getString(R.string.targetnamespace), getResources().getString(R.string.usernameavailabilitymethod));
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
PropertyInfo piUserName = new PropertyInfo();
piUserName.name = "UserName";
request.addProperty(piUserName, sUserName);
HttpTransportSE httpTransport = new HttpTransportSE(getResources().getString(R.string.webserviceurl));
try {
httpTransport.debug =true;
httpTransport.call(getResources().getString(R.string.usernameavailabilitysoapaction), envelope);
SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
if (!response.toString().equals("false")) {
result = true;
}
//else
//{
// alertBox("User Name already exists.Please enter different username.");
// }
}catch (Exception exception) {
Log.w("UserNameAvailability - RegisterActivity", "Error message is "+exception.getMessage(), exception);
}
return result;
}
登錄貓細節
01-16 18:02:01.956: W/UserNameAvailability - RegisterActivity(241): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643)
01-16 18:02:01.956: W/UserNameAvailability - RegisterActivity(241): at android.view.ViewRoot.handleMessage(ViewRoot.java:1691)
01-16 18:02:01.956: W/UserNameAvailability - RegisterActivity(241): at android.os.Handler.dispatchMessage(Handler.java:99)
01-16 18:02:01.956: W/UserNameAvailability - RegisterActivity(241): at android.os.Looper.loop(Looper.java:123)
01-16 18:02:01.956: W/UserNameAvailability - RegisterActivity(241): at android.app.ActivityThread.main(ActivityThread.java:4363)
01-16 18:02:01.956: W/UserNameAvailability - RegisterActivity(241): at java.lang.reflect.Method.invokeNative(Native Method)
01-16 18:02:01.956: W/UserNameAvailability - RegisterActivity(241): at java.lang.reflect.Method.invoke(Method.java:521)
01-16 18:02:01.956: W/UserNameAvailability - RegisterActivity(241): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
01-16 18:02:01.956: W/UserNameAvailability - RegisterActivity(241): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
01-16 18:02:01.956: W/UserNameAvailability - RegisterActivity(241): at dalvik.system.NativeStart.main(Native Method)
01-16 18:13:43.946: I/ActivityManager(51): Displayed activity com.anb.eCalculator/.LoginActivity: 1988 ms (total 1988 ms)
01-16 18:13:45.996: I/ActivityManager(51): Starting activity: Intent { cmp=com.anb.eCalculator/.RegisterActivity }
01-16 18:13:56.002: W/ActivityManager(51): Launch timeout has expired, giving up wake lock!
01-16 18:13:56.073: W/ActivityManager(51): Activity idle timeout for HistoryRecord{44d9f420 com.anb.eCalculator/.RegisterActivity}
01-16 18:14:00.764: I/ActivityManager(51): Displayed activity com.anb.eCalculator/.RegisterActivity: 14756 ms (total 14756 ms)
01-16 18:14:16.317: W/KeyCharacterMap(241): No keyboard for id 0
01-16 18:14:16.317: W/KeyCharacterMap(241): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
01-16 18:14:18.587: D/ViewFlipper(91): updateRunning() mVisible=true, mStarted=false, mUserPresent=true, mRunning=false
01-16 18:14:18.587: D/ViewFlipper(91): updateRunning() mVisible=true, mStarted=false, mUserPresent=true, mRunning=false
我無法從Web服務獲得結果。我是android開發新手。我懷疑我的代碼是否有錯誤的Web服務請求。任何人都會指導我。 – Prakash 2012-01-16 12:39:34
您發佈Logcat輸出的異常情況。 – 2012-01-16 12:42:05
我得到一個空指針異常。 – Prakash 2012-01-16 12:47:42