0

Following is the code for Web services at android devices. I done exactly the way I watched In a youtube Video. There is no any error showing, still cant get the result on my AVD. The result should be " I am passing a static value in Celsius and need to get Convert the value in Fahrenheit". When I run app on AVD there is nothing happen even though there is no any error too.

package com.example.mushtaqali.testapp1;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
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 org.ksoap2.transport.HttpTransportSE;


import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

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

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        tv=(TextView)findViewById(R.id.textView);

        SoapObject request=new SoapObject(NAMESPACE, METHOD_NAME);
        request.addProperty("Celsius", "32");

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

        HttpTransportSE aht=new HttpTransportSE(URL);
        try {
            aht.call(SOAP_ACTION, soapEnvelope);
            SoapPrimitive resultString=(SoapPrimitive)soapEnvelope.getResponse();
            //SoapObject result= (SoapObject)soapEnvelope.bodyIn;
            tv.setText("Status : " +  resultString);
        }
        catch (Exception e){

            e.printStackTrace();
        }
    }
}
Rao
  • 20,781
  • 11
  • 57
  • 77
Mushtaq
  • 29
  • 6
  • check whether yoy have given Internet permission or what , and include this line of code in your java file StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); – Sudhir Belagali Jan 13 '16 at 07:02
  • Brother. I am alreaady allowed Internet permission in Manifest.xml . And the videos i watched on youtube. They did the same coding. the only prob is " I am using android sutdio while they used Eclipse". rest evrything is same. I have tried the line of codes you given buh still no results. – Mushtaq Jan 13 '16 at 13:04

0 Answers0