Android Web Service Learning Summary (i)

Source: Internet
Author: User
Tags soap wsdl

Recently learning Android platform Call Webwebservice, learned a nice blog (http://blog.csdn.net/lyq8479/article/details/6428288), unfortunately is the method of 2011, And not suitable for the Android version after android4.0 now, so through a study and research, summarized as follows.

Introduction to Web Service popular understanding: By using WebService, we are able to invoke methods on remote servers just 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.Web Services is based on common protocols such as HTTP, SOAP, and WSDL, so it isnecessary to understand the SOAP and WSDL, which is used later in the development example.
1.SOAP, Simple Object access Protocol, is a lightweight, simple, XML-based protocol that is designed to exchange simple protocols for formatting and curing 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. 2.WSDL (webservices Description Language, or Web Service Description Language ) is an XML language used to describe Web Services , which describes the functions, interfaces, parameters, The return value, etc., 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 an XML document that describes all aspects of a webserivce. For example, to provide WebService mobile phone number related information query site http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx?wsdl, Open the link to see an XML document, and all we have to do is read the useful information from it and use it later in the call process. The following is part of the XML file:
1 This XML file does does appear to has any style information associated with it. The document tree is shown below.2 <wsdl:definitionsXmlns: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/"xmlns:wsdl= "http://schemas.xmlsoap.org/wsdl/"targetnamespace= "http://WebXml.com.cn/">3 <wsdl:documentationxmlns:wsdl= "http://schemas.xmlsoap.org/wsdl/">4 <ahref= "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, monthly update.<BR/>Use the Site WEB services please specify or link to this site:<ahref= "http://www.webxml.com.cn/"Target= "_blank">http://www.webxml.com.cn/</a>Thank you for your support!<BR/>&nbsp;5 </wsdl:documentation>6 <Wsdl:types>7 <S:schemaelementFormDefault= "qualified"targetnamespace= "http://WebXml.com.cn/">8 <s:elementname= "Getmobilecodeinfo">9 <S:complextype>Ten <s:sequence> One <s:elementminOccurs= "0"maxOccurs= "1"name= "Mobilecode"type= "S:string"/> A <s:elementminOccurs= "0"maxOccurs= "1"name= "UserID"type= "S:string"/> - </s:sequence> - </S:complextype> the </s:element> - <s:elementname= "Getmobilecodeinforesponse"> - <S:complextype> - <s:sequence> + <s:elementminOccurs= "0"maxOccurs= "1"name= "Getmobilecodeinforesult"type= "S:string"/> - </s:sequence> + </S:complextype> A </s:element> at ...... - </wsdl:definitions>

With this file, we need to obtain the following information:

1) xmlns:soap12= "http://schemas.xmlsoap.org/wsdl/soap12/" from code line number 2 to learn that the SOAP protocol version is SOAP1.2

2) targetnamespace= "http://WebXml.com.cn/" from code line number 2 to know the namespace "http://WebXml.com.cn/

3) from the code line number 8 learned that the query number attribution to call Method name "Getmobilecodeinfo"

4) from the code line 11, 12, respectively, the call this method requires 2 arguments string type Mobilecode and UserID

5) learned from code line 19 that calling this method returns a result string named Getmobilecodeinforesult

The preparation of the specific invocation process is broadly described above. See Android Web Service Learning summary for specific process (ii)

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.