请任何人帮我解决这个bug。下面是主要的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;
}
}抛出空指针异常...我不知道为什么它会被抛出。我怎样才能得到正确的回答?有谁能帮我一下吗?提前谢谢。
发布于 2016-01-14 11:48:46
移动
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);在发送请求之前,您不会获得数据
信封正文as /Out initial as null,这就是为什么你会得到NPE
https://stackoverflow.com/questions/11339718
复制相似问题