Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6617531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:42:57+00:00 2026-05-25T20:42:57+00:00

I am using the following code to to access web service and it’s showing

  • 0

I am using the following code to to access web service and it’s showing me an error. The application is not responding.

package com.android.webservice;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class WebServiceActivity extends Activity {
    private static final String SOAP_ACTION = "http://tempuri.org/HelloWorld";

    private static final String METHOD_NAME = "HelloWorld";

    private static final String NAMESPACE = "http://tempuri.org/";
    private static final String URL = "http://192.168.1.19/TestWeb/WebService.asmx";


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);



        Button getquote = (Button) findViewById(R.id.getquote);  
        getquote.setOnClickListener(new OnClickListener() {  

        public void onClick(View v) { 
            TextView result1;
            result1=(TextView)findViewById(R.id.result1);
        try {


            SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
            EditText CompanyName = (EditText) findViewById(R.id.CompanyName); 
            String val1 = (CompanyName.getText().toString());
            request.addProperty("passonString", val1);

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

            HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
            androidHttpTransport.call(SOAP_ACTION, envelope);

            Object result = (Object)envelope.getResponse();

            result1.setText(result.toString());
        } catch (Exception e) {

            result1.setText(e.getMessage());
            }
    }
});
    }
}

May be because this is running in UI thread, I want to run it in background using handler. I am new in this field so I’m having problems to write it in background thread. Can anyone please give me directions on how to write the code inside handler?
Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T20:42:57+00:00Added an answer on May 25, 2026 at 8:42 pm

    try this::
    AsyncTask enables proper and easy use of the UI thread. This class allows to perform background operations and publish results on the UI thread without having to manipulate threads and/or handlers.

    An asynchronous task is defined by a computation that runs on a background thread and whose result is published on the UI thread. An asynchronous task is defined by 3 generic types, called Params, Progress and Result, and 4 steps, called onPreExecute, doInBackground, onProgressUpdate and onPostExecute

         private class xyz extends AsyncTask<Void, Void, Void> {
        private final ProgressDialog dialog = new ProgressDialog(tranning.this);
    
        @Override
        protected void onPreExecute() {
            this.dialog.setMessage("Please Wait...");
            this.dialog.show();
            // put your code which preload with processDialog  
        }
    
    
        @Override
        protected Void doInBackground(Void... arg0) {
            // put your code here
            return null;
        }
    
        @Override
        protected void onPostExecute(final Void unused) {
            if (this.dialog.isShowing()) {
              this.dialog.dismiss();
    
            }   
        }
    }
    

    and use this in main ::

    new xyz().execute();
    

    For more Elaboration
    . . . . . . . . . .
    . . . . . .
    . . . .
    . .
    .

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using following PHP code to connect to MS Access database: $odb_conn =
I have a flex 4.6 application calling a web service that access a MS
I am building a small website for fun/learning using a fairly standard Web/Service/Data Access
I am using following code in rowdatabound function. Protected Sub gvwMileStone_RowDataBound(ByVal sender As System.Object,
I am using following code to check whether a check box on my website
I am using following code to design my home page. The output (as shown
I'm using following code but cannot return data from MySQL. This is the output:
I open a pop-up window using following code in main.html function openwindow(url) { window.open(url,
I am setting the row height of my UITableView using following code [tableView setRowHeight:
Using the following code I get a nice formatted string: Request.QueryString.ToString Gives me something

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.