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 7075383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:10:15+00:00 2026-05-28T06:10:15+00:00

I am new to Eclipse and Android programming in general but I have been

  • 0

I am new to Eclipse and Android programming in general but I have been tasked to create an app for my company that will connect to our SQL Server to read some data as proof of concept. I have downloaded and installed Eclipse Eplison and the Java/Android SDK’s needed. I wanted to start simple so I created an app with a button and a view on it and it builds and works fine. I then created a simple WebService in .NET (vs2010) and have it running on my localhost. Navigating to it works find (via IE) and it works as planned. Here’s the code for the webservice (called Service1.asmx):

    [WebMethod]
    public string DisplayText(string TextToDisplay)
    {
        return TextToDisplay;
    }

Now I’m trying to make the button call the webservice and display whatever text is passed in. Here’s the code I am using in Eclipse:

package com.test.android;

import org.ksoap2.*;
import org.ksoap2.serialization.*;
import org.ksoap2.transport.*;

import android.app.*;
import android.os.*;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

public class ServiceUI extends Activity {
/** Called when the activity is first created. */

private static final String SOAP_ACTION = "http://localhost/MyWebService/DisplayText";
private static final String MethodName = "DisplayText";
private static final String NameSpace = "http://tempuri.org/"; // "http://localhost/testservice/";
private static final String URL = "http://localhost/MyWebServices/Service1.asmx?wsdl";
TextView tv;

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

    tv=(TextView)findViewById(R.id.tvMessage);

    Button btn = (Button)findViewById(R.id.btnPress);
    btn.setOnClickListener(btnListener);
}

public void CallWebService()
{
try { 
        SoapObject request = new SoapObject(NameSpace, MethodName);         
        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

        envelope.dotNet=true; 
        request.addProperty("TextToDisplay", "This is coming from android");
        envelope.setOutputSoapObject(request); 

        androidHttpTransport.call(SOAP_ACTION, envelope); 

        SoapObject result = (SoapObject)envelope.getResponse(); 
        tv.setText( ""+result); 
    } 
    catch (Exception e) { 
        tv.setText(e.getMessage()); 
    }       
}

private OnClickListener btnListener = new OnClickListener()
{
    public void onClick(View v)
    {
        CallWebService();
    }
};
}

When I run it in my AVD, I get the following error:
localhost/127.0.0.1:80 – Connection Refused

Any ideas why? I’ve looked at many, many links on here regarding asmx and eclipse but I wasn’t able to find one that referenced my “Connection Refused” error.

Any help is greatly appreciated!

  • 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-28T06:10:15+00:00Added an answer on May 28, 2026 at 6:10 am

    Try the ip address of 10.0.2.2 instead of localhost for your URI.

    Check out:
    this url

    Scroll about half-way down and look for ‘Network Address Space’

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

Sidebar

Related Questions

I'm fairly new to Android programming and to Java in general, but I have
I am new to programming in general and have been teaching myself using Android
I'm trying to create a new project in eclipse for an android app, and
I am new to Android programming. I have installed the Eclipse and Android SDK.
I'm new to android programming, but one thing that I can't seem to get
I'm new to Eclipse/Java/Android I have already created this project, but I wanted to
I know that eclipse can do this, can Intellij via the new Android support
I'm new to Eclipse/Android development so I'm hoping this is something basic that I'm
I'm new to publishing Android apps. Our app's name and the string that users
I am using eclipse as IDE for android programming. I have update android SDK

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.