【问题标题】:android ksoap error in httptransportse.call();httptransportse.call() 中的 android ksoap 错误;
【发布时间】:2012-07-05 07:33:15
【问题描述】:

请任何人帮助我解决这个错误...这是 ma Java 代码:

public class MainActivity extends Activity implements Serializable {

    private static final String Url = "http://c.knotbiz.com/knotbizjob.asmx";
    private static final String Namespace = "http://tempuri.org/";
    private static final String methodName = "UploadFile";
    private static final String Soap_Action = "http://tempuri.org/UploadFile";

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        handlerobj.post(runnableobj);    
    }

    private Handler handlerobj = new Handler();

    private Runnable runnableobj = new Runnable() {

        public void run() {
            // TODO Auto-generated method stub

            Bitmap bitmapOrg = BitmapFactory.decodeResource(getResources(),
                    R.drawable.ic_launcher);
            ByteArrayOutputStream bao = new ByteArrayOutputStream();
            bitmapOrg.compress(Bitmap.CompressFormat.PNG, 90, bao);
            byte[] ba = bao.toByteArray();

            Log.v("Base64>>>>>>>",""+ Base64.encodeBase64(ba) );

            long user_id = 3;

            boolean Is_Created = false,Is_Overwrite = true,Is_resize = true;
            String FileName = "Hishamdocument";

            String FileType = "png";

            //Base64.encodeBase64(ba)

            SoapObject req = new SoapObject(Namespace, methodName);

            req.addProperty("UserId", user_id);

            req.addProperty("File", FileName);

            req.addProperty("FileName", FileName);

            req.addProperty("FileType", FileType);

            req.addProperty("isCreated", Is_Created);

            req.addProperty("Abspath", "");

            req.addProperty("FullPath", "");

            req.addProperty("IsOverwrite", Is_Overwrite);

            req.addProperty("IsResize", Is_resize);

            req.addProperty("Id", user_id);

            req.addProperty("SendEmailId", user_id);


            Log.v("Request>>>>>>>", req.toString());


            //SoapEnvelope              

            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

            envelope.dotNet = true;             

            envelope.setOutputSoapObject(req);

            try{
            Log.v("envelope body in", envelope.bodyIn.toString());

            Log.v("envelope", envelope.toString());


            Log.v("envelope body Out", envelope.bodyOut.toString());

            }

            catch(Exception e) {

                Log.e("errror", ""+e);

            }               

            //httpTransportSe

            try{
            HttpTransportSE httpreq = new HttpTransportSE(Url);
            httpreq.debug = true;

            Log.v("inside httpreq"," envelope.bodyOut.toString()");

            httpreq.call(Soap_Action, envelope);


            Log.v("inside httpreq"," envelope.bodyOut.toString()");

            Log.v("After call httpreq",httpreq.responseDump.toString());



            }
            catch(Exception e){
                e.printStackTrace();
            }
        }
    };

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }

}

抛出空指针异常......我不知道为什么会抛出它......我怎样才能得到正确的响应?请任何 1 帮助我吗?...在​​此先感谢。

【问题讨论】:

  • 哪一行会抛出错误?堆栈跟踪 ?猫日志?在这里给我们一块骨头......
  • 我的 httptranspotobj.requestDump 为空...请任何 1 帮助我///
  • envelope.BodyIn 也是空的...并且说不能序列化..at httptransportseobj.call();

标签: java android ksoap httptransportse


【解决方案1】:

移动

        Log.v("envelope body in", envelope.bodyIn.toString());
        Log.v("envelope", envelope.toString());
        Log.v("envelope body Out", envelope.bodyOut.toString());

之后

httpreq.call(Soap_Action, envelope);

在你发送请求之前你不会得到数据

信封bodyIn/Out初始为null,这就是你得到NPE的原因

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-06-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多