这是我的代码,我遇到了异常,我无法解决请帮助我,我正在尝试使用 webservice 做 android 应用程序。使用 gateOut 方法计算今天有多少船门
package com.example.marport;
import java.io.IOException;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.SoapFault;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import org.xmlpull.v1.XmlPullParserException;
import android.app.Activity;
import android.app.ProgressDialog;
import android.os.AsyncTask;
import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class LimanBilgileri extends Activity
{
/** Called when the activity is first created. */
final static String NAMESPACE = "http://webservice.marport.dcat.com/";
// Web servis üzerinde hangi metodu kullanacağımızı ayarlıyoruz.
final static String METHOD_NAME = "gateOut";
// SOAP_ACTION : NAMESPACE ve METHOD_NAME birleşiminden oluşuyor.
final static String SOAP_ACTION = "http://webservice.marport.dcat.com/gateOut";
// Son olarak Web servise ait URL tanımlamasını burada yapıyoruz.
final static String URL = "192.168.1.164:8070/test/services/MarportWebServicePort";
private TextView sonuc;
private EditText deger;
private Button hesapla;
private TextView debug;
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.limanbilgileri);
debug=(TextView)findViewById(R.id.textView3);
deneme den=new deneme();
den.execute();
}
public class deneme extends AsyncTask<String, String, String>{
private final ProgressDialog dialog = new ProgressDialog(LimanBilgileri.this);
String result=null;
protected void onPostExecute(String unused) {
this.dialog.dismiss();
debug.setText("sonuc " +unused);
}
protected void onPreExecute() {
this.dialog.setMessage("Yükleniyor...");
this.dialog.show();
}
@Override
protected String doInBackground(String... params) {
// TODO Auto-generated method stub
SoapObject Request=new SoapObject(NAMESPACE,METHOD_NAME);
//Request.addProperty();
SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
soapEnvelope.dotNet=false;
soapEnvelope.setOutputSoapObject(Request);
HttpTransportSE aht=new HttpTransportSE(URL);
try {
aht.call(SOAP_ACTION, soapEnvelope);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (XmlPullParserException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
result= soapEnvelope.getResponse().toString();
} catch (SoapFault e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return result;
}
}
}
这里有例外
08-16 12:43:42.867: E/AndroidRuntime(2892): FATAL EXCEPTION: AsyncTask #1
08-16 12:43:42.867: E/AndroidRuntime(2892): java.lang.RuntimeException: An error occured while executing doInBackground()
08-16 12:43:42.867: E/AndroidRuntime(2892): at android.os.AsyncTask$3.done(AsyncTask.java:299)
08-16 12:43:42.867: E/AndroidRuntime(2892): at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
08-16 12:43:42.867: E/AndroidRuntime(2892): at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
08-16 12:43:42.867: E/AndroidRuntime(2892): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
08-16 12:43:42.867: E/AndroidRuntime(2892): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
08-16 12:43:42.867: E/AndroidRuntime(2892): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
08-16 12:43:42.867: E/AndroidRuntime(2892): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
08-16 12:43:42.867: E/AndroidRuntime(2892): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
08-16 12:43:42.867: E/AndroidRuntime(2892): at java.lang.Thread.run(Thread.java:856)
08-16 12:43:42.867: E/AndroidRuntime(2892): Caused by: java.lang.NullPointerException
08-16 12:43:42.867: E/AndroidRuntime(2892): at org.ksoap2.serialization.SoapSerializationEnvelope.getResponse(SoapSerializationEnvelope.java:552)
08-16 12:43:42.867: E/AndroidRuntime(2892): at com.example.marport.LimanBilgileri$deneme.doInBackground(LimanBilgileri.java:90)
08-16 12:43:42.867: E/AndroidRuntime(2892): at com.example.marport.LimanBilgileri$deneme.doInBackground(LimanBilgileri.java:1)
08-16 12:43:42.867: E/AndroidRuntime(2892): at android.os.AsyncTask$2.call(AsyncTask.java:287)
08-16 12:43:42.867: E/AndroidRuntime(2892): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
08-16 12:43:42.867: E/AndroidRuntime(2892): ... 5 more