无法在本地服务器上使用KSoap2发布数据

时间:2013-12-14 06:29:06

标签: android api ksoap2

我有一个.net Api在服务器上发送数据。我正在使用KSoap2发布该数据但是没有做到。我正在使用代码

protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        new backMethod().execute(); // This is an important Step 
    }
    public class backMethod extends AsyncTask<String, Object, Object > {

     private final ProgressDialog dialog = new ProgressDialog(MainActivity.this);

     @Override
     protected void onPreExecute() {

         this.dialog.setMessage("Checking...");               
         this.dialog.show();   
    }


     @Override
     protected void onPostExecute(Object result) {
          //Here All your UI part is Done

           if (result != null) {            

               TextView tv=(TextView)findViewById(R.id.textView1);
                tv.setTag(result);         

           } else {
             Toast.makeText(getApplicationContext(),
             "Result Found is ==  " + result + "", Toast.LENGTH_LONG).show();

           }
              super.onPostExecute(result);
              if (this.dialog.isShowing()) {

              this.dialog.dismiss();
           }
              super.onPostExecute(result);
           }


           @Override
              protected Object doInBackground(String... params) {

               SoapObject request = new SoapObject(NAMESPACE, OPERATION_NAME);

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

                 HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);

                 androidHttpTransport.call(SOAP_ACTION, envelope);

                 response = (SoapObject) envelope.getResponse();
                     //here SoapPrimitive is an important part  

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

                  }
                     return response;
                   }

虽然调试代码流自动移动到catch块并且找不到异常网络。

0 个答案:

没有答案