0

HERE İS MY CODE i am getting exceptions and i can not solve please help me i am trying to do android application with webservice.calculating howmany ship gateout for today with using gateOut method

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;
        }

    }
}

HERE İS EXCEPTİON

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
Tunç Doğan
  • 73
  • 1
  • 2
  • 8

3 Answers3

0

Sounds like you service returns nothing from your request. Maybe you should ensure that your SOAP request is correct.

Aerilys
  • 1,628
  • 1
  • 16
  • 22
0

The exception is generated here:

result= soapEnvelope.getResponse().toString();

Probably you did something wrong before that line. E.g. soapEnvelope is maybe not initialized correctly. Or the request must be executed first?

More exactly the error is in SoapSerializationEnvelope.java:552 (which is executed by this call above). But as you did not post this file, we cannot check that.

--- edit ---

I found a version of this file here: http://code.google.com/p/salesforceandroid/source/browse/trunk/SalesforceAndroid/src/org/ksoap2/serialization/SoapSerializationEnvelope.java?r=93 ; seems to be a different version of that file (as there is no line number 552); But there is a method getResonse():

public Object getResponse() throws SoapFault {
    if (bodyIn instanceof SoapFault) {
        throw (SoapFault) bodyIn;
    }
    KvmSerializable ks = (KvmSerializable) bodyIn;
    return ks.getPropertyCount() == 0 ? null : ks.getProperty(0);
}

The only reason why this should produce a null-pointer exception is that "bodyIn" (an internal variable) is null. This variable is initialized either in the parseBody() method or in parseXml() of that object. So this must be called first, before you can successfully execute getResponse();

OR: if this part is maintained by you... the variable "bodyIn" must be initialized elsewhere in your objects life cycle.

SDwarfs
  • 3,189
  • 5
  • 31
  • 53
-1

Maybe this helps, for me worked:

if (android.os.Build.VERSION.SDK_INT > 9) 
{
    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
    StrictMode.setThreadPolicy(policy);
}

see Android http connection exception

Community
  • 1
  • 1
marisxanis
  • 109
  • 8