WebService ----android客户端

 android端调用ksoap方法时,间隔性的报空指针错误。org.ksoap2.transport.httptransportSE.call  nullPointerException。

 搜索到的解决方法如下:

public String SoapAction(String[] values){

String[] data = new String[] { "CompanyID", "Username", "Password", "indexNo", "DataString","lDate" };

SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

for(int i = 0; i < data.length; i++){
PropertyInfo property = new PropertyInfo();
property.setName(data[i]);
property.setNamespace(NAMESPACE);
property.setType(PropertyInfo.STRING_CLASS);
property.setValue(values[i]);

request.addProperty(property);
}

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

try{
HttpTransportSE http = new HttpTransportSE(URL);
http.debug = true;
System.setProperty("http.keepAlive", "false");

http.call(SOAP_ACTION, envelope);
}catch (IOException e1) {
e1.printStackTrace();
return "serverError";
} catch (XmlPullParserException e1) {
e1.printStackTrace();
return "serverError";
} catch (Exception e) {
e.printStackTrace();
return "serverError";
}

SoapPrimitive resultString = null;

try{
resultString = (SoapPrimitive)envelope.getResponse();
}catch (SoapFault e) {
e.printStackTrace();
return "serverError";
}

if(resultString != null){
return resultString.toString();
} else {
return "serverError";
}
}


还遇到一个问题,百度定位sdk在tab里面不能实现定位,注册位置监听函数,但是程序执行时根本不执行监听代码。或许和activity的生命周期有关,程序中调用了拍照跟能。


你可能感兴趣的:(webservice)