Webserviceandroidsoapweb Service Serviceweb
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
- <? XML version= "1.0" encoding="Utf-8" ?>
- <wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
- xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
- xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
- xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
- xmlns:tns="http://WebXml.com.cn/"
- xmlns:s="Http://www.w3.org/2001/XMLSchema"
- xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
- xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
- targetnamespace="http://WebXml.com.cn/"
- xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
- <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
- <a href="http://www.webxml.com.cn/" mce_href="http://www.webxml.com.cn/" target= "_blank">webxml.com.cn</a>
- <strong> Domestic mobile phone number attribution to query Web Services </Strong, provide the latest domestic mobile phone number segment attribution data, updated monthly. <br />
- 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/
- </A> Thank you for your support! <br />
- </wsdl:documentation>
- <wsdl:types>
- <s:schema elementformdefault="qualified" targetnamespace="http://WebXml.com.cn/ " >
- <s:element name="Getmobilecodeinfo">
- <s:complextype>
- <s:sequence>
- <s:element minoccurs= "0" Maxoccurs= "1" name= " Mobilecode " type=" s:string " />
- <s:element minoccurs="0" maxoccurs="1" name="UserID" type="S:string" />
- </s:sequence>
- </s:complextype>
- </s:element>
- <s:element name="Getmobilecodeinforesponse">
- <s:complextype>
- <s:sequence>
- <s:element minoccurs="0" maxoccurs="1" name="Getmobilecodeinforesult" Type="s:string" />
- </s:sequence>
- </s:complextype>
- </s:element>
- ... ...
- </s:schema>
- </wsdl:types>
- ... ...
- </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 back.