Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I've programmed ( actually followed a tutorial ) simple web service in android, using Ksoap libary. But it seems that it doesn't work well. Below is my simple code:

public class MainActivity extends Activity {

TextView tv;
SoapPrimitive response;

final String SOAP_ACTION = "http://tempuri.org/CelsiusToFahrenheit";
final String METHOD_NAME = "CelsiusToFahrenheit";
final String NAMESPACE = "http://www.tempuri.org/";
final String URL = "http://www.w3schools.com/webservices/tempconvert.asmx";
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    tv = (TextView) findViewById(R.id.tv);
    final Button button = (Button) findViewById(R.id.button1);
    button.setOnClickListener(new View.OnClickListener() {

        @Override 
        public void onClick(View v) {
            getValue();

        }
    });

}

private void getValue() {

    SoapObject soapObject = new SoapObject(NAMESPACE, METHOD_NAME);
    soapObject.addProperty("Celsius", "33");


    SoapSerializationEnvelope serial = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    serial.dotNet = true;
    serial.setOutputSoapObject(soapObject);

    HttpTransportSE transport = new HttpTransportSE(URL);

    try {
        transport.call(SOAP_ACTION, serial);
        response = (SoapPrimitive) serial.getResponse();
        tv.setText(response+"");
    } catch (IOException e) {
        e.printStackTrace();
    } catch (XmlPullParserException e) {
        e.printStackTrace();
    }

}
}

I only get a response "Error" in my text view. Can anyone tell me what is wrong here?

share|improve this question
    
Why negative vote? Please explain.. –  rootpanthera Jul 11 '13 at 16:32

1 Answer 1

up vote 0 down vote accepted

I found what was wrong. I wrote:

final String NAMESPACE = "http://www.tempuri.org/";

instead of

final String NAMESPACE = "http://tempuri.org/";

It's working now.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.