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

  • SEARCH
  • Home
  • 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 8135043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:16:27+00:00 2026-06-06T10:16:27+00:00

Right now i am consuming two webservices by the method SOAP on android.The way

  • 0

Right now i am consuming two webservices by the method SOAP on android.The way of consuming the webservice is just getting the input from the user and showing it in textviews.Well its working fine.But i’m trying to show that answer in tabs of a tabhost which consists of two tabs.Im trying to show the answer from the first webservice is to be shown in first tab of a tabhost and the answer from the second webservice is to be show in second tab of the same tabhost…

But here the problem is, its showing the same answer on the two tabs,how to overcome this problem?

NOTE: Im using the same edittext and button for getting the input from the user for both webservices.

I have four activities namely,

  • Demo_tabActivity.java [main activity]
  • tabhost.java

The below two activities are tabs of the above

  • Tab_1.java
  • Tab_2.java

The first activity(Demo_tabActivity.java) contains an edittext & button.The second(Tabhost.java) activity contains a Tabhost widget.The third & fourth activities contains textviews respectively.

The first activity is going to consume a web service by getting the input from the user and returns some data on first tab(third activity) of a tabhost(second activity).
Like wise it will consume the another webservice.

Please find my code below

Demo_tabActivity.java

public class Demo_tabActivity extends Activity 
{
private static String NAMESPACE1 = "http://tempuri.org/";
private static String NAMESPACE2 = "http://tempuri.org/";
private static String METHOD_NAME1 = "FahrenheitToCelsius";
private static String METHOD_NAME2 = "CelsiusToFahrenheit";
private static String SOAP_ACTION1 = "http://tempuri.org/FahrenheitToCelsius";
private static String SOAP_ACTION2 = "http://tempuri.org/CelsiusToFahrenheit";
private static String URL1 = "http://www.w3schools.com/webservices/tempconvert.asmx?WSDL";
private static String URL2 = "http://www.w3schools.com/webservices/tempconvert.asmx?WSDL";
Button btnFar;
EditText txtFar;

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

       btnFar = (Button)findViewById(R.id.button1);
       txtFar = (EditText)findViewById(R.id.editText_in);
       btnFar.setOnClickListener(new View.OnClickListener()

       {
       public void onClick(View v)
       {
         String b;
         String b2;

         //Initialize soap request + add parameters
         SoapObject request = new SoapObject(NAMESPACE1, METHOD_NAME1);
         SoapObject req = new SoapObject(NAMESPACE2, METHOD_NAME2);
         //Use this to add parameters
         request.addProperty("Fahrenheit",txtFar.getText().toString());
         request.addProperty("Celsius",txtFar.getText().toString());

         //Declare the version of the SOAP request

         SoapSerializationEnvelope envelope = new     SoapSerializationEnvelope(SoapEnvelope.VER11);
         SoapSerializationEnvelope env = new SoapSerializationEnvelope(SoapEnvelope.VER11);

         envelope.setOutputSoapObject(request);
         env.setOutputSoapObject(req);
         envelope.dotNet = true;

         try 
         {
             HttpTransportSE androidHttpTransport = new HttpTransportSE(URL1);
             HttpTransportSE androidHttpT = new HttpTransportSE(URL2);

             //this is the actual part that will call the webservice
             androidHttpTransport.call(SOAP_ACTION1, envelope);
             androidHttpT.call(SOAP_ACTION2, env);          

             // Get the SoapResult from the envelope body.

             SoapPrimitive result = (SoapPrimitive)envelope.getResponse();
             SoapPrimitive res = (SoapPrimitive)envelope.getResponse();


             if (result != null && res != null)
             {
              //Get the first property and change the label text

                b = result.toString();
                b2 = res.toString();
                Intent myIntent = new Intent(v.getContext(), Tabhost.class);
                myIntent.putExtra("gotonextpage", b);
                myIntent.putExtra("goto", b2);
                startActivity(myIntent);
             }
             else
             {
               Toast.makeText(getApplicationContext(), "No Response",Toast.LENGTH_SHORT).show();
             }
         }
        catch (Exception e)
        {
           e.printStackTrace();
           }
         }
       });
   }
}

Tabhost.java

 public class Tabhost extends TabActivity {


@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.main1);

    String result;
    String result2;

    Bundle extras = getIntent().getExtras();
    Bundle extras2 = getIntent().getExtras();

    if(extras!=null)
    {
        result = extras.getString("gotonextpage");

    } else result = "Didnt work !" ;

    if(extras2 !=null)
    {
        result2 = extras2.getString("goto");

    } else result2 = "Didnt work !" ;



    TabHost tabHost = getTabHost();
    TabHost.TabSpec spec;
    Intent intent;

    intent = new Intent().setClass(this, Tab_1.class);
    intent.putExtra("result", result);
    spec = tabHost.newTabSpec("first").setIndicator("First").setContent(intent);
    tabHost.addTab(spec);

    intent = new Intent().setClass(this, Tab_2.class);
    intent.putExtra("result2", result2);
    spec = tabHost.newTabSpec("second").setIndicator("Second").setContent(intent);
    tabHost.addTab(spec);

    tabHost.setCurrentTab(0);


}
}

Tab_1.java

public class Tab_1 extends Activity 
{
TextView tv1;
String result;

/** Called when the activity is first created. */

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

Bundle extras = getIntent().getExtras();
if(extras != null)
{   
    result = extras.getString("result");
} else result = "didnt work";


tv1 = (TextView)findViewById(R.id.textView_main2);
tv1.setText(result);
}
 }

Tab_2.java

 public class Tab_2 extends Activity {

String result2;
TextView tv2;

/** Called when the activity is first created. */   

@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.main3);

    Bundle extras2 = getIntent().getExtras();
    if(extras2 != null) {   
        result2 = extras2.getString("result2");
    } else result2 = "didnt work";

    tv2 = (TextView)findViewById(R.id.textView_main3);
    tv2.setText(result2);

    }
 }

Thanks for your help!..

  • 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-06-06T10:16:30+00:00Added an answer on June 6, 2026 at 10:16 am

    There are few silly mistakes in your code. Please do the corrections:

    Change the particular lines of code:

      1) SoapPrimitive res = (SoapPrimitive)envelope.getResponse();
    

    with

       SoapPrimitive res = (SoapPrimitive)env.getResponse();
    
      2)request.addProperty("Celsius",txtFar.getText().toString());
    

    with

        req.addProperty("Celsius",txtFar.getText().toString());
    

    You will get the result.

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

Sidebar

Related Questions

i am self-leaner to android.Right now i am consuming web service in android eclipse
I'm consuming a webservice from another company, they have multiple versions running, each newer
Can any one differentiate Fragments and shared preferences on android. Because, Right now i
I am developing a windows mobile app. Right now I am just testing that
Right now I am using std::pair to represent a 2d point in c++. However,
Right now I have this SQL query which is valid but always times out:
Right now I have def min(array,starting,ending) minimum = starting for i in starting+1 ..ending
Right now I have double numba = 5212.6312 String.Format({0:C}, Convert.ToInt32(numba) ) This will give
Right now I currently using transactional replication with updatable subscription. Is there any ways
Right now I convert the string containing the decimal number to an integer (ignoring

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.