问题
i am new to android/eclipse(java),in fact this forum too.
Has any one met this situation?
Get input from the user and display the appropriate result by consuming web service from android/eclipse.is there any examples available?
Thank you very much.
回答1:
I am posting Link of tutorial
Here basic android tutorial to access web service in android basic ksoap android tutorial
and for creating webservice in java use this Tutorial How to create java based web service
Write a web service using java and Then by using ksoap library you will get response. Then Format that response according to your requirement. code for reference:
private static final String NAMESPACE = "http://tempuri.org/";
private static final String URL ="http://localhost/Web_Service.asmx?";// replace it by your Webservice URL
private static final String METHOD_NAME = "Function_Name";
private static final String SOAP_ACTION = "Soap Action";
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("parm_name",prm_value);// Parameter for Method
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try
{
androidHttpTransport.call(SOAP_ACTION, envelope);//call the eb service Method
}
catch (Exception e)
{
e.printStackTrace();
}//Next task is to get Response and format that response
SoapObject response;
response= (SoapObject) envelope.bodyIn;
回答2:
there are too may example for same Please Google ..................
this is only for initiation
Soap
http://android.vexedlogic.com/2011/04/17/android-lists-iv-accessing-and-consuming-a-soap-web-service-i/
http://seesharpgears.blogspot.in/2010/11/basic-ksoap-android-tutorial.html
Other
http://webhole.net/2011/11/15/android-tutorial-how-to-post-data-from-an-android-app-to-a-website/
http://apachejava.blogspot.in/2011/06/partial-http-post-show-data-webview.html
http://senior.ceng.metu.edu.tr/2009/praeda/2009/01/11/a-simple-restful-client-at-android/
来源:https://stackoverflow.com/questions/10892637/webservices-on-android-eclipse