Click here to Skip to main content
16,019,272 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Please Help Me It Doesn't Work

This Is My Code
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
 
public class Mainactivity extends Activity {
 
	private Button ButtonCall;
 
	  private static String SOAP_ACTION1 = "http://tempuri.org/HelloWorld";
		private static String SOAP_ACTION2 = "http://tempuri.org/Ring";
		private static String NAMESPACE = "http://tempuri.org/";
	    private static String METHOD_NAME1 = "HelloWorld";
		private static String METHOD_NAME2 = "Ring";
		private static String URL = "http://mobiletest.somee.com/Service1.asmx?WSDL";
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.my_service);
		
		
		ButtonCall = (Button)findViewById(R.id.button1);
		ButtonCall.setOnClickListener(new OnClickListener() {
			
			private TextView CallingText;
 
			public void onClick(View arg0) {
				//Initialize soap request + add parameters
		    	SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME2);        
		    	
		    	//Use this to add parameters
		    	request.addProperty("Ringu","Ring");
		    	
		    	//Declare the version of the SOAP request
		    	SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
		    	
		    	envelope.setOutputSoapObject(request);
		    	envelope.dotNet = true;
		    	
		    	
		    	try {
		    		HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
		    		
		    		//this is the actual part that will call the webservice
		    		androidHttpTransport.call(SOAP_ACTION2, envelope);
		    		
		    		// Get the SoapResult from the envelope body.
		        	SoapObject result = (SoapObject)envelope.bodyIn;
 
		        	if(result != null)
		        	{
		        		//Get the first property and change the label text
		        		CallingText = (TextView)findViewById(R.id.TEXTVIEW1);
		        		CallingText.setText(result.getProperty(0).toString());
			    	}
		        	else
		        	{
		        		Toast.makeText(getApplicationContext(), "No Response",Toast.LENGTH_LONG).show();
		        	}
		    	} catch (Exception e) {
		    		e.printStackTrace();
		    	}
			}
		});
	
 
}
Posted
Updated 21-Oct-12 1:28am
v2
Comments
joshrduncan2012 22-Oct-12 11:17am    
We can't decipher what the error is from just the code. We need you to provide us an error message and where the compiler is pointing to. Please use Improve Question and supply us with that information so we can better assist you. "Please Help Me It Doesn't Work" won't work for us.
azhar eqbal 12-Nov-12 3:20am    
Can u post the logcat

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900