Android personal learning notes-use myeclipse to quickly create webservice and call (CONTINUE) in Android. androidmyeclipse

Source: Internet
Author: User

Android personal learning notes-use myeclipse to quickly create webservice and call (CONTINUE) in Android. androidmyeclipse
2. Android webservice call

Package net. zmqc. service; import org. ksoap2.SoapEnvelope; import org. ksoap2.serialization. soapObject; import org. ksoap2.serialization. soapSerializationEnvelope; import org. ksoap2.transport. httpTransportSE; public class InfoWebService {public static String soapCallWebService (double p_x, double p_y) {String result = "no data appears !!!!!!!! "; String url =" http: // 127.0.0.1: 8080/InfoGpsService/InfoServicePort "; String nameSpace =" http://service.zmqc.net/"; // call the method String methodName =" getInfoList "; // create the httpTransportSE transmission object HttpTransportSE ht = new HttpTransportSE (url); ht. debug = true; // use the soap1.1 protocol to create the Envelop object SoapSerializationEnvelope envelope = new SoapSerializationEnvelope (SoapEnvelope. VER11); // instantiate SoapObject object SoapObject request = new SoapObject (nameSpace, methodName); // set parameters. The parameter name may not necessarily be the same as the parameter name on the called server, you only need to make the request in the same order. addProperty ("arg0", p_x + ""); request. addProperty ("arg1", p_y + ""); envelope. bodyOut = request; try {// web service request ht. call (null, envelope); // obtain the returned data result = envelope. getResponse (). toString ();} catch (Exception e) {// TODO: handle finished tione. printStackTrace (); result = "connection error";} return result ;}}

Ksoap is used for calling. It is the ksoap2-.. jar package and can be downloaded from Baidu.
In this way, you can obtain it in the activity. The function of this Android app is mainly to complete positioning, and the positioning longitude and latitude are used as parameters to call the web service. Then, a json string is returned, parse the string to obtain Information.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.