[Reading Notes] iOS-use Web Service-network communication based on client server structure (I), ios-service-

Source: Internet
Author: User

[Reading Notes] iOS-use Web Service-network communication based on client server structure (I), ios-service-

Web Service is a Service provided through the Web protocol to ensure that application services on different platforms can interoperate and provide different services for client programs.

At present, three mainstream Web Service implementation solutions are used: REST, SOAP and XML-RPC.XML-RPC and SOAP are more complex technology, XML-PRC is the predecessor of SOAP.

1. REST Web Service.

REST is translated as "representation state transfer", which sounds abstract. "representation" is the page seen by the client, and the page Jump is the status transfer, the client requests the URL to obtain the page to be displayed. REST is generally based on existing protocols and standards such as HTTP, URI, XML, and HTML.

1. HTTP and HTTPS protocols.

The Web Servie application layer uses transmission protocols such as HTTP and HTTPS.

1) HTTP protocol.

HTTP is a hypertext transfer protocol. It is an object-oriented protocol at the application layer. It is suitable for the transmission of distributed hypertext information in a simple and fast manner. It proposed in 1990 that, after several years of use and development, it is constantly improved and expanded. The HTTP protocol supports the network structure of the client server. There is no connection protocol, that is, to establish a connection for each request. After the server completes processing the client's request, it will answer the question to the client and then disconnect, without occupying network resources.

The GET method sends a request to a specified resource. The sent information is displayed after the URL. The GET method should be used only for reading data, such as static images. The GET method is like using a postcard to write a letter to someone else. The "letter content" is written outside and can be seen by people who come into contact with it, so it is not safe.

The POST method submits data to a specified resource and requests the server for processing. For example, submit a table but upload a Wei file. Data is contained in the request body. The POST method is a bit like loading the "email content" into an envelope and writing letters to others. People who contact it cannot see it, so it is safe.

2) HTTPS protocol

HTTPS is a Secure Hypertext Transfer protocol. Is a combination of Hypertext Transfer Protocol and SSL, providing encrypted communication and identification of network servers.

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.

The POST method is recommended for HTTP requests. This is because the GET requests are static resources and the data transmission process is not secure. The POST method mainly requests dynamic resources, many parameters are required for calling these methods.

In viewWillAppear: the number of network requests that can be called for query in the method increases. When a large amount of data is returned, the screen displays slowly.

Ii. SOAP Web Service

1. WSDL concept.

WSDL is the XML format used to describe the Web Service Release.

WDSL is an XML Schema document that defines the XML document structure, similar to DTD. if you understand an XML document as a database, XML Schema defines the create, drop, and alter statements of the database structure.

2. SOAP protocol.

3. Example: SOAP Web Service implements My Notes application.

Commonly used: test/plain stands for plain text, text/html stands for HTML documents, application/pdf stands for PDF documents, and application/msword is a Microsoft Word file, the special application/SOAP + xml in soap; charset = UTF-8 represents the xml soap format document, the charset = uft-8 is the character set of the document.

Iii. Use of the ASIHTTPRequest framework.

Advantages of the ASIHTTPRequest framework:

1. Data can be downloaded and stored in memory or local files.

2. It is easy to access requests and respond to HTTP headers.

3. Supports cookies;

4. Supports GZIP requests or responses;

5. Supports caching.

6. synchronous or asynchronous requests are supported.

7. HTTPS is supported.

 

 

Reference: iOS network programming and cloud applications-Best Practices

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.