"Reading notes" ios-network communication using the Web service-based on the client server architecture (i)

Source: Internet
Author: User
Tags representational state transfer wsdl

Web Service technology is a kind of service through Web protocol, which ensures that application services of different platforms can interoperate and provide different services for client programs.

At present, 3 kinds of mainstream Web service implementations are used: Rest,soap and XML-RPC.XML-RPC and soap are more complex technologies, XML-PRC is the predecessor of SOAP.

One, REST Web Service.

Rest is translated as "representational State transfer", which sounds abstract, "characterization" is the page that the client sees, and the page jumps to the state, and the client obtains the page to be displayed by requesting the URL. Rest is typically based on these existing protocols and standards, such as Http,uri and XML, and HTML.

1,http and HTTPS protocols.

The Web servie application layer uses transport protocols such as HTTP and HTTPS.

1) HTTP protocol.

HTTP is a Hypertext Transfer protocol. is an object-oriented protocol belonging to the application layer, because of its simple and fast way, it is suitable for the transmission of distributed hypertext information. It was proposed in 1990, after several years of use and development, and constantly improve and expand. The HTTP protocol supports the client server network structure. is a no-connection protocol, to establish a connection on each request, the server after processing the client's request, then to the client and then disconnected, not always occupy network resources.

The Get method makes a request to the specified resource, and the information sent is displayed behind the URL, and the Get method should be used to read data only, such as static pictures. The Get method is like using a postcard to write to someone, "the content of the letter" is written outside, accessible to anyone can see, and therefore unsafe.

The Post method submits data to the specified resource and requests the server to process it. For example: Submit a form but or a document such as Wei. The data is included in the request body. The Post method is a bit like putting the "letter content" into an envelope to write to someone else, and it is safe to see people that are not in contact with them.

2) HTTPS protocol

HTTPS is a secure Hypertext Transfer protocol. is a combination of Hypertext Transfer Protocol and SSL that provides encrypted communication and authentication of the identity of the network server.

2, synchronous get method request programming

3, asynchronous get method request programming.

4,post method Request programming.

5, Example: Mynotes application implemented by REST Web Servie.

Using the HTTP method request method, it is recommended to use the Post method, because get requests static resources, the data transfer process is not secure, and post mainly requests dynamic resources, these method calls need to pass a lot of parameters.

Implementation of query calls in the Viewwillappear: method increases the number of network requests, and for large amounts of data returns, the screen appears to be slow.

Second, the SOAP Web Service

1,WSDL concept.

WSDL is an XML format for describing a Web service publication.

WDSL is an XML Schema document that defines the structure of an XML document, similar to a DTD. If an XML document is understood as a database, the XML schema is the Create,drop and ALTER statement that defines the database structure.

2,SOAP protocol.

3, Example: SOAP Web Service implements my Notes app.

Commonly used are: Test/plain represents plain text, text/html represents HTML documents, Application/pdf represents PDF documents, Application/msword is a Microsoft Word file, A bit of a special application/soap+xml;charset=utf-8 in SOAP represents the XML SOAP format document, and the latter charset=uft-8 refers to the document's character set.

Third, the use of the ASIHTTPRequest framework.

Advantages of the ASIHTTPRequest framework:

1, support to download data in memory or local files.

2, easy access to request and answer HTTP header.

3, support cookies;

4, support gzip request or answer;

5, supports caching.

6, supports synchronous or asynchronous requests.

7, support HTTPS.

Reference: "iOS network programming and cloud applications-best practices"

"Reading notes" ios-network communication using the Web service-based on the client server architecture (i)

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.