Discussion Forums  >  Uncategorized

Replies: 0    Views: 516

jtech.03
Android Fan
Profile
Posts: 1
Reg: Jan 15, 2012
mumbai
10
01/17/12 04:21 AM (14 years ago)

error calling web services in Android applications

plz help me.. this is my java code package com.samples.zarca; import org.ksoap2.SoapEnvelope; import org.ksoap2.serialization.Marshal; import org.ksoap2.serialization.MarshalFloat; import org.ksoap2.serialization.SoapObject; import org.ksoap2.serialization.SoapPrimitive; import org.ksoap2.serialization.SoapSerializationEnvelope; import org.ksoap2.transport.HttpTransportSE; import android.app.Activity; import android.os.Bundle; import android.widget.TextView; public class MyTestActivity extends Activity { * Called when the activity is first created. */ 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://w3schools.com/webservices/tempconvert.asmx; TextView tv; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); tv=(TextView)findViewById(R.id.text1); call(); } public void call() { try { SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); request.addProperty(Celsius, 32); SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER12); envelope.dotNet=true; envelope.setOutputSoapObject(request); Marshal floatMarshal = new MarshalFloat(); floatMarshal.register(envelope); HttpTransportSE androidHttpTransport = new HttpTransportSE(URL); androidHttpTransport.call(SOAP_ACTION, envelope); SoapPrimitive result = (SoapPrimitive)envelope.getResponse(); tv.setText(result + result.toString()); } catch (Exception e) { tv.setText(got some error : + e.getMessage()); } } }
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.