我是android / eclipse(java)的新手,实际上也是这个论坛。
有没有人遇到过这种情况?
从用户那里获取输入并通过使用android / eclipse中的web服务显示相应的结果。有没有可用的例子?
非常感谢。
答案 0 :(得分:1)
我发布了教程链接
这里是访问android basic ksoap android tutorial
中的Web服务的基本android教程并且要在java中创建webservice,请使用此教程How to create java based web service
使用java编写Web服务然后使用ksoap库您将获得响应。然后根据您的要求格式化响应。代码供参考:
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;
答案 1 :(得分:0)
也有相同的例子请谷歌..................
这仅适用于启动
肥皂
http://seesharpgears.blogspot.in/2010/11/basic-ksoap-android-tutorial.html
其他
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/