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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:58:20+00:00 2026-06-15T11:58:20+00:00

Sorry im new to android development and i am trying to access a web

  • 0

Sorry im new to android development and i am trying to access a web service though kSoup2…

The code is as follows

    package com.example.mytestws;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.AndroidHttpTransport;

import android.os.Bundle;
import android.widget.TextView;
import android.app.Activity;


public class MainActivity extends Activity {

    private static final String SOAP_ACTION="http://tempuri.org/CelsiusToFahrenheit";
    private static final String METHOD_NAME="CelsiusToFahrenheit";
    private static final String NAMESPACE="http://tempuri.org/";
    private static final String URL="http://www.w3schools.com/webservices/tempconvert.asmx";
    TextView tv;

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

        tv=(TextView) findViewById(R.id.textView1);
        SoapObject Request=new SoapObject(NAMESPACE, METHOD_NAME);
        Request.addProperty("Celcius", "32");
        SoapSerializationEnvelope soapEnvelope=new SoapSerializationEnvelope(SoapEnvelope.VER11);
        soapEnvelope.dotNet=true;
        soapEnvelope.setOutputSoapObject(Request);

        AndroidHttpTransport aht=new AndroidHttpTransport(URL);

        try{
            aht.call(SOAP_ACTION, soapEnvelope);
            SoapPrimitive resultString=(SoapPrimitive) soapEnvelope.getResponse();
            tv.setText(resultString.toString());
        }
        catch(Exception e){

            //e.printStackTrace();
        }


    }

}

and the manifest is as follows:

    <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.mytestws"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="1"
        android:targetSdkVersion="7" />
    <uses-permission android:name="android.permission.INTERNET"/>

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.mytestws.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

I am receiving the output as “Error” instead of the actual string returned through the web service.. Can you please help me sort this problem out?

  • 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-15T11:58:21+00:00Added an answer on June 15, 2026 at 11:58 am

    Defined the following code which is:

    SoapPrimitive resultString=(SoapPrimitive) soapEnvelope.getResponse();
    

    as the following:

    SoapObject resultString = (SoapObject)envelope.bodyIn;
    

    and do the follwoing after that:

    if(resultString != null)
                    {
                          tv.setText(resultString.toString());
                    }
    

    and also do not do any network operation in main thread, instead you can do it in AsyncTask.

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

Sidebar

Related Questions

New with Android. Sorry! I'm trying to create the following... Wait for Timer to
I'm relatively new to java and android development so sorry if this is a
I'm new to Android development, so sorry if this question can be answered easily,
I'm looking for concept explanations or example code, if possible I'm new to (android)
Hi im new to Android development.. Sorry. My Android App crashes as i am
First- sorry if my question a bit dumb, I'm totally new to Android development
Sorry that I am very new to the android development and now that I
Sorry, I'm new to flash I have this line of code: BaseEntry( _entryList[i] ).topTeamName
I'm new in Android development and I have been making a tutorial for a
I'm new in Android development and I've a problem when I create my new

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.