RSS

How to call a .NET web service from android?

27 May

Hai, Finally i got the solution for my own question.

Here is the code:

package projects.ksoap2sample;

import org.ksoap2.SoapEnvelope; import org.ksoap2.serialization.SoapObject; import org.ksoap2.serialization.SoapSerializationEnvelope; import org.ksoap2.transport.HttpTransportSE; import android.app.; import android.os.; import android.widget.TextView;

public class ksoap2sample extends Activity { /** Called when the activity is first created. */ private static final String SOAP_ACTION = “http://tempuri.org/HelloWorld”;

private static final String METHOD_NAME = "HelloWorld"; private static final String NAMESPACE = "http://tempuri.org/"; private static final String URL = "http://192.168.1.19/TestWeb/WebService.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("passonString", "Rajapandian");         SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);         envelope.dotNet=true;         envelope.setOutputSoapObject(request);         HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);         androidHttpTransport.call(SOAP_ACTION, envelope);         Object result = (Object)envelope.getResponse();         tv.setText(result.toString());     } catch (Exception e) {         tv.setText(e.getMessage());         } } 

}

Regards Rajapandian

Referenced by: http://stackoverflow.com/questions/1048310/how-to-call-a-net-web-service-from-android

Advertisements
 
1 Comment

Posted by on May 27, 2011 in Android, Mobile Development

 

One response to “How to call a .NET web service from android?

  1. Raed

    June 5, 2011 at 9:33 AM

    Dude U R Hero

    Thanx

     

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: