WebService introduction of Android development

Source: Internet
Author: User
Tags wsdl

Often a netizen asked: "How to invoke WebService on Android platform"? After communication I found that even some friends do not know what is Webserivce is asking how to use, let alone and webservice related to the SOAP, WSDL, such as "Mars" noun. So, I would like to explain how the Android platform to call Webserivce before the introduction of the next WebServiceto see how mysterious it is.
I remember that my master's thesis included the word "Web service", and it took a lot of time to study the application of Web service in system integration and enterprise application integration. At work, several projects that are exposed to the Web service Now take some time out of work to learn Android and Web Service. It seems that Web service is ubiquitous, where there is a programming language where it can always be found ( hint: If you have not contacted WebService before, it is necessary to know that WebService is not an Android patent, 10几 years ago).

Web Services is a software system that supports different machine interoperability between networks, a self-contained, self-describing, and modular application that can be described, published, and invoked in the network as a network-based, distributed, modular component, according to the definition of the website.
WEB services are built on the basis of common protocols, such as HTTP, SOAP, UDDI, WSDL, and so on, which have no inclination to choose the operating system, programming language and object model, and therefore have strong vitality.
The advantage of Web services is that it provides interoperability between different application platforms, which enables component-based development and Web integration to work best. It is based on the HTTP protocol, the call request and the response message can pass through the firewall, do not need to change the firewall settings, so as to avoid the use of special ports to communicate with the problem of unable to cross the firewall.

Simple comprehension: What we call a webservice is a server that is remotely exposed to a service, or understood to expose a function or method to the outside, and we can programmatically invoke the service to get the information we need. For example: www.webxml.com.cn has publicly disclosed the mobile phone number attribution to the service, we only need to call the service when a mobile phone number segment (number), we can immediately obtain the information of the number segment.
More common understanding: by using WebService, we are able to invoke methods on remote servers like local methods. We don't need to worry about whether the remote method is written in Java or written in PHP or C #, and we don't need to care whether the remote approach is based on UNIX or Windows, which means WebService is not related to the platform or language.

      SOAP (Simple Object access Protocol) is a lightweight, simple, XML-based protocol that A simple protocol designed to exchange formatting and hardening information in a distributed environment. In other words, to communicate, data access transmission, you must rely on a certain protocol, and SOAP is the WebService communication is dependent on a protocol.       WSDL (Web Services Description Language, or Web Service Description language) is an XML language used to describe a Web service. It describes the functions, interfaces, parameters, return values, etc. of the Web service, which makes it easy for users to bind and invoke services. It defines related actions and messages for a given Web service invocation and response in a language-neutral way.
      WSDL is something we can actually see, an XML document that describes every aspect of a webserivce. For example, the above mentioned that the www.webxml.com.cn website provides a cell phone number attribution to query the Webserivce, how do we use this webserivce? Which version of the SOAP protocol is it based on? What parameters do I need to pass in calling it? What value does it return? Is it a string or an XML document? This series of questions can be found in the WSDL. The WSDL address of the above service is: HTTP://WEBSERVICE.WEBXML.COM.CN/WEBSERVICES/MOBILECODEWS.ASMX?WSDL, which is accessed on the browser, you will see an XML document as follows:
      

[XHTML]View Plaincopy
  1. <? XML version= "1.0" encoding="Utf-8" ?>
  2. <wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
  3. xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
  4. xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
  5. xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
  6. xmlns:tns="http://WebXml.com.cn/"
  7. xmlns:s="Http://www.w3.org/2001/XMLSchema"
  8. xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
  9. xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
  10. targetnamespace="http://WebXml.com.cn/"
  11. xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
  12. <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
  13. <a href="http://www.webxml.com.cn/" mce_href="http://www.webxml.com.cn/" target= "_blank">webxml.com.cn</a>
  14. <strong> Domestic mobile phone number attribution to query Web Services </Strong, provide the latest domestic mobile phone number segment attribution data, updated monthly. <br />
  15. Use the Site WEB services please specify or link to this site:<a href="http://www.webxml.com.cn/" mce_href= "/http www.webxml.com.cn/" target="_blank ">http://www.webxml.com.cn/
  16. </A> Thank you for your support! <br />
  17. </wsdl:documentation>
  18. <wsdl:types>
  19. <s:schema elementformdefault="qualified" targetnamespace="http://WebXml.com.cn/ " >
  20. <s:element name="Getmobilecodeinfo">
  21. <s:complextype>
  22. <s:sequence>
  23.                          <s:element  minoccurs= "0"   Maxoccurs= "1"  name= " Mobilecode " type=" s:string "  />  
  24. <s:element minoccurs="0" maxoccurs="1" name="UserID" type="S:string" />
  25. </s:sequence>
  26. </s:complextype>
  27. </s:element>
  28. <s:element name="Getmobilecodeinforesponse">
  29. <s:complextype>
  30. <s:sequence>
  31. <s:element minoccurs="0" maxoccurs="1" name="Getmobilecodeinforesult" Type="s:string" />
  32. </s:sequence>
  33. </s:complextype>
  34. </s:element>
  35. ... ...
  36. </s:schema>
  37. </wsdl:types>
  38. ... ...
  39. </wsdl:definitions>


What information can we get from seeing the WSDL?
1) from the No. 08 line, it can be seen that the Webserivce is based on the SOAP protocol version is SOAP1.2;
     2) from line 10th, it can be seen that the Webserivce namespace (NameSpace) is http://webxml.com.cn/            3) from the 20th line can be seen, we query the cell phone number attribution to the method name to be called: getmobilecodeinfo;
            4) from the 第23-24 line can be seen, We need to pass in two parameters when we call the Getmobilecodeinfo method: Mobilecode and userid;
            5) as you can see from line 31st, after calling the Getmobilecodeinfo method, A result string named Getmobilecodeinforesult is returned.
      here, we have a preliminary understanding of Webserivce, as well as soap and WSDL. With this knowledge in place, you can start WebService related development work. The next article will explain how to programmatically call this Webserivce on the Android platform and get the results returned

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.