Google for the Ksoap2 tutorial and get a lot of them. Here is a sample code to send a request to a web service.
public class WebServicePoc extends Activity{ private static final String SOAP_ACTION = "http://tempuri.org/Arnoid"; private static final String METHOD_NAME = "Arnoid"; private static final String NAMESPACE = "http://tempuri.org/"; private static final String URL = "http://ipaddress:port/UserAuthenticationInterfacer.asmx"; EditText editText; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); HashMap<String, String> a=new HashMap<String, String>(); try { SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); request.addProperty("FOSID", "1994"); request.addProperty("IMEINumber", ""); request.addProperty("SIMCardNo", ""); request.addProperty("ApplicationName", "App"); request.addProperty("CurrentVersion", "1.0.0.0"); SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); envelope.dotNet=true; envelope.setOutputSoapObject(request); AndroidHttpTransport androidHttpTransport = new AndroidHttpTransport(URL); androidHttpTransport.call(SOAP_ACTION, envelope); SoapObject result = (SoapObject)envelope.getResponse(); editText=(EditText)findViewById(R.id.text1); editText.setText(result.toString()); } catch (Exception e) { e.printStackTrace(); }
And to check xml pls for xml parsers, use only SAX, since STAX is not supported in android. To send an xml request, you can send xml as a string and then decode on the server side.
source share