如何在web服务android中使用asynctask

时间:2014-08-19 06:16:30

标签: android web-services

这个web服务在2.3安卓工作正常但在4.0及以上版本工作时我在4.0中加载相同的应用程序它强制关闭应用程序请帮我这个

public int call1()
{
    try
    {

        SoapObject request = new SoapObject(NAMESPACE1, METHOD_NAME1);
        //           request.addProperty("CompanyNmae", a); //           request.addProperty("ShopNumber", b); //           
        request.addProperty("LicenseNumber", c); //         
        request.addProperty("RecipientName", d); //         
        request.addProperty("Fine", DD2);

        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.dotNet = true;
        envelope.setOutputSoapObject(request);

        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL1);
        androidHttpTransport.call(SOAP_ACTION1, envelope);
        // HttpResponse response = request.execute(androidHttpTransport);
        // Object result = envelope.getResponse();

        Object result = envelope.getResponse();
        Result = result.toString();

        // Toast.makeText(this, Result, Toast.LENGTH_LONG).show();
        //Result = result.getProperty(1).toString();
        // Result = result.getAttribute("CompanyName").toString(); //           Result = result.getProperty(2).toString();
        //           textView3 = (TextView) findViewById(R.id.textView3); //             //              //         
        textView3.setText(Result);
        // Toast.makeText(this, Result, Toast.LENGTH_LONG).show();
        return 1;

    }
    catch (Exception e)
    {
        Toast.makeText(this, "Error in Method 'Call' ", Toast.LENGTH_LONG).show();
        //Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show();

        return 0;
    }
}

这是我的错误日志:

08-19 11:20:56.348: E/AndroidRuntime(5583): FATAL EXCEPTION: main 08-19 11:20:56.348: E/AndroidRuntime(5583): java.lang.NullPointerException 
08-19 11:20:56.348: E/AndroidRuntime(5583): at com.inventorymanagement.Password.Customer(Password.java:440)

08-19 11:20:56.348: E/AndroidRuntime(5583): at com.inventorymanagement.Password.access$2(Password.java:396) 
08-19 11:20:56.348: E/AndroidRuntime(5583): at com.inventorymanagement.Password$2.onClick(Password.java:127) 
08-19 11:20:56.348: E/AndroidRuntime(5583): at android.view.View.performClick(View.java:4212) 
08-19 11:20:56.348: E/AndroidRuntime(5583): at android.view.View$PerformClick.run(View.java:17476) 
08-19 11:20:56.348: E/AndroidRuntime(5583): at android.os.Handler.handleCallback(Handler.java:800) 
08-19 11:20:56.348: E/AndroidRuntime(5583): at android.os.Handler.dispatchMessage(Handler.java:100) 
08-19 11:20:56.348: E/AndroidRuntime(5583): at android.os.Looper.loop(Looper.java:194) 
08-19 11:20:56.348: E/AndroidRuntime(5583): at android.app.ActivityThread.main(ActivityThread.java:5371) 
08-19 11:20:56.348: E/AndroidRuntime(5583): at java.lang.reflect.Method.invokeNative(Native Method) 
08-19 11:20:56.348: E/AndroidRuntime(5583): at java.lang.reflect.Method.invoke(Method.java:525) 
08-19 11:20:56.348: E/AndroidRuntime(5583): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833) 
08-19 11:20:56.348: E/AndroidRuntime(5583): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) 
08-19 11:20:56.348: E/AndroidRuntime(5583): at dalvik.system.NativeStart.main(Native Method)

0 个答案:

没有答案