This section introduces the two main interface types of Web services, namely SOAP-style Web services and REST-style Web services, which are also known as SOAP APIs and REST APIs. It should be emphasized that Web services are not limited to these two types. Web programs that transmit formatted data over HTTP should be considered Web services. SOAP, formerly known as the Simple Object Access Protocol, uses an encapsulated XML for information exchange. In 2003, it was adopted by the World Wide Web Consortium as a recommended standard. Later, people thought that the full name “Simple Object Access Protocol” was easy to misunderstand, so the World Wide Web Consortium abandoned the full name in 2007, and now people just use the abbreviation of SOAP. SOAP-style Web services use HTTP Post and SOAP-encapsulated XML to send requests and pass results between clients and servers (Figure 3.7). SOAP-based Web services encapsulate the body of XML information in another XML envelope. This “XML-in-XML” format is not convenient for people to manually create SOAP requests and parse SOAP results, making it difficult to invoke SOAP services. Of course, there are tools that can simplify the invocation of SOAP services. SOAP-based Web services generally have WSDL( Web Service Description Language), which is the Web Service Description Language. It describes the specific programming interface provided by a Web service in XML format, making it easy for developers to understand and use the Web service. For example, the Fig. 28 SOAP-based Web services rely on HTTP Post and SOAP-encapsulated XML to send requests and pass results between clients and servers # Fig. 29 Web services published by ArcGIS Server support both SOAP and REST interfaces. The upper left figure shows the Web service description language of an ArcGIS Server map service, and the lower right figure shows that Microsoft Visual Studio generates local API functions based on WSDL # Web services have SOAP-style interfaces and their WSDL(Figure 3. 8), some clients such as ArcMap and ArcGIS Explorer Desktop communicate with ArcGIS Server via SOAP. REST(representational state transfer) is an architectural style proposed by Roy Fielding in his doctoral thesis in 2000. Roy Fielding was involved in the formulation of the HTTP specification. He believed that SOAP did not make full use of the advantages of HTTP. The REST-style architecture he proposed could give full play to the advantages of HTTP, reduce development complexity, and improve system scalability (Richardson and Ruby,2007). REST did not receive much attention when it was first proposed. Its concepts and principles were relatively abstract, and different people’s interpretations were different. It has not been fully observed or implemented in real applications. REST-style Web services send data over HTTP, and the information sent is not encapsulated in SOAP. The most common way to implement this is to put the request parameters in the URL and send the request parameters through the URL. REST-style Web services often return results to clients in JS0N and XML without SOAP encapsulation. Figure 3.9 shows that the same functions in Figure 3.8 are implemented in a REST format. It can be seen that the REST interface is more concise than the SOAP interface. Fig. 30 In the most common REST implementation, all requests are URLs, and the names and values of parameters in the request are placed in the URL, rather than SOAP-encapsulated XMI. # In REST-style Web services, each resource corresponds to a URI (Uniform Resource Identifier). In loose cases, a URI can be understood as a URL. These URLs often form a hierarchy. For example, there are many services published on an ArcGIS Server, and their corresponding URIs are The URL corresponding to one of the map services named “ESRI_StreetMap_World_2D” is to add the service name and service category (MapServer) after the above URL, that is The URL corresponding to the first data layer in this map service is to add 0 to the rear of the above URL (the first layer counts from zero) As you can see, the URL hierarchy of this directory structure is intuitive, predictable, and easy to understand, does not require too much documentation, and developers can easily build these URLs to point to the Web resources they need. Web resources in REST services support specific operations. For example, a map service can perform mapping and query operations, and a single data layer in a map service can perform query operations. The results of these operations can be returned to the client in a format such as JSON. For example, if you request an ArcGIS Server map service to make a map of the United States through the REST interface, you will need to return an 800 pixel x 500 pixel JPEG image. The URL request is roughly Using REST to query the median household income of each county in California in an ArcGIS Server map service, the request is returned to the JS0N format. The URL request is roughly It can be seen that basically all requests in REST are a URL, which is relatively easy to understand. You can use many programming languages, such as. NET, Java JavaScript, and Flex, to generate this URL string and send this URL request. You can even directly put this URL into your Web browser without programming and see the map and other results you want. Therefore, REST is considered the “command line of the Web.” Table 3.1 compares SOAP and REST-type Web services. SOAP-type Web services were born early, the related technologies are relatively mature, and are widely used. Their interfaces are clearly and strictly defined, and the development environment supports them with a high degree of support. However, it is too complex, making programming workload and difficulty; it does not fully utilize the advantages of HTTP, resulting in low transmission efficiency; SOAP encapsulation makes the transmitted XML complex and huge, which often reduces the efficiency of information transmission and parsing and even the performance of the entire system. Given these realizations, people are gradually turning to style Web services that are simple and efficient (ere et al., 2007)。In many cases, the simplicity and efficiency of REST outweigh the rigour of adopting SOAP (Fu et al., 2008). 表3.1比较SOAP类型的Web服务和REST类型的Web服务 SOAP-type Web services REST-type Web services transmission mode HTTP POST Mainly HTTP GET; although the semantics and usages of PUT, P0ST, and DELETE are defined, they are rarely used in practice request parameters Put it in XML and encapsulate it in SOAP Parameters (key-value pairs) are usually placed in the URL response result Put it in XML and encapsulate it in SOAP Parameters (key-value pairs) are usually placed in the URL response result Put it in XML and encapsulate it in SOAP Various, including JSON, XML(non-SOAP encapsulated), binary file streams, etc. advantages Early and mature, rigorous interface, powerful functions Lightweight, simple and efficient, can make full use of the advantages of Web caching and other advantages, and is gradually widely used. disadvantages Heavy-duty, complex, and high-threshold;SOAP encapsulated XML information transmission efficiency and parsing efficiency are low; cannot fully utilize the advantages of HTTP Not rigorous enough, a little casual In 2002, Amazon released its Web service for e-commerce transactions, and also provided two Web service interfaces: SOAP and REST for users to choose from. A few years later, these services attracted a large number of users, and statistics show that 80% of requests received by Amazon servers are REST-based, while only 20% are SOAP-based (Greenfield and Doman,2004). The advantages of REST over SOAP are reflected in the following aspects: For service providers, the cost of creating services and the cost of service hosting can be reduced; For developers who do application development based on Web services, it can reduce the difficulty of people, shorten learning time, speed up development, and reduce development costs; For managers, REST provides a better system architecture and achieves higher system response speed, high reliability and scalability. Fig. 31 ArcGISServer’s Web services have both SOAP and REST interfaces. # When you are using ArcMap and ArcGIS Explorer desktop, you are using the SOAP interface ArcGIS Server provides both SOAP and REST Web services interfaces (Figure 3. 10), ArcGISDesktop and ArcGIS Explorer Desktop call ArcGIS Sever’s services through the SOAP interface, while the ArcGIS APIs for JavaScript, Flex, Silverlight and the smartphone APIs provided by ArcGIS call ArcGIS Sever’s services through the REST interface.SOAP-style Web services #


RESTful Web services #

http://server.arcgisonline.com/ArcGIS/test/Services
http://feerver.arcgisonline.com/ArcGIS/rest/Services/ESRI_StreetMap_World_2D/MapServer
http://server.mycompany.com/ArcGIS/rest/services/QSMap/MapServer/export?
bbox=-185.33,15.20,-9 .53,74.08&size=800,500&format=jpg&dpi=96&f=image
http://server.mycoinpany.com/ArcGIS/rest/services/USMap/MapServ-er/0/query?
where=STATE_NAME ='Calif ornia'&outFields =MEDHINC_CY &f =pjson
Comparison of SOAP and REST #
