Link to home
Start Free TrialLog in
Avatar of GlobaLevel
GlobaLevelFlag for United States of America

asked on

android to consume a .net web service

I am using a few links to create a web service in my android....they make it sound like copy and paste code..but when I did that..I am getting all these errors...like:

1)Soap object cannot be resolved
2)envelope.setOutputSoapObject(request); >>>>UNDEFINED
3)  Object result = (Object)envelope.getResponse(); >>>>GETRESPONSE IS UNDEFINED
4)    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); >>>>CANNOT BE RESOLVED TO A VARAIBLE....

also how can I consume this into a dataset?
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; 

import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;




 public class COG_APP_12_10_2011Activity 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://webxxxxx.com/COG_WS_AxxxxxxxxV3D9KLL.asmx"; 
	    TextView tv; 
	 
	    // ------------------------------------------------------------------
	    @Override 
	    public void onCreate(Bundle savedInstanceState) { 
	       super.onCreate(savedInstanceState); 
	        setContentView(R.layout.main); 
	       tv=(TextView)findViewById(R.id.text1); 
	       // CONSUME .NET WEB SERVICE
	        call(); 
	        // SETUP SPLASH PAGE....
	        setupSplash();
	 
	   } 
	    //--------------------------------------------------------------------
	 
	    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()); 
	            } 
	    }

Open in new window

Avatar of GlobaLevel
GlobaLevel
Flag of United States of America image

ASKER

Any ideas...can I put the web service code in the same .java file as main activity, it seems to be forcing me into creating new java files...
ASKER CERTIFIED SOLUTION
Avatar of Darren
Darren
Flag of Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Curious if there is any existing code...