Summary:REST: The short name of the representational state transition (representational, Transfer), which defines how the Web standards should be used correctly. At present, my level is not enough to understand the rest of the point, even slightly understand the fur has not reached. Just read "In Layman's Rest", but also do not understand, below this article summarizes the rest of the five key principles listed.
REST: The short name of the representational state transition (representational, Transfer), which defines how the Web standards should be used correctly.
At present, my level is not enough to understand the rest of the point, even slightly understand the fur has not reached. Just read "In Layman's Rest", but also do not understand, below this article summarizes the rest of the five key principles listed.
1. Define ID for all "things": Use a URI to identify all the things that are worth identifying, especially all the "advanced" resources provided in the app, whether they represent a single data item, a collection of data items, a virtual or actual object, or a calculation result.
2. Link all things together: wherever possible, use links to guide things (resources) that can be identified. It's the hyperlinks that make up the web today.
3, using the standard method: In order to enable the client program to work with your resources, resources should be correctly implemented by the default application protocol (HTTP), that is, the use of standard GET, PUT, post and Delete methods.
4. Multiple representations of resources: providing multiple representations of resources for different needs.
5, non-state communication.
My own understanding is that rest is a Web schema.
I. Introduction to the ArcGIS REST API
The ArcGIS REST API provides a simple, open interface for accessing and using services published by ArcGIS Server. With the ArcGIS REST API, you can get and manipulate all of the resources and operations in each service through a URL. The above statement is important, indicating that using the rest API (which is the ArcGIS Rest API, which is generally called the ArcGIS Rest API) is actually a URL to the GIS server to get the resources of the operation (this is my current understanding, welcome to point out the improper understanding of the place). For example, to access a GIS Server through the rest API, you can use a URL in the following format:
1. Java:
Http:
2,. NET:
Http://
For example, to access my own computer: Http://localhost/arcgis/rest/services. After you enter this address in the browser's address bar, you can see a page like this:
The address above is also called the base address. Addresses provide access to all of the resources and operations associated with the service.
The rest API is stateless, which means that rest does not hold information between the two requests, so each request must contain information that can be successfully processed.
second, the service endpoint (Server end point)
Each arcgisserver will provide a services Directory. Servicesdirectory is the HTML-formatted view of the Arcgisserver Rest API. This view allows you to browse the contents of ArcGIS Server and get information, such as the metadata of the service and the actions that are supported when the application is developed. Each instance of ArcGIS server creates this services Directory when it is initialized.
The entire servicedirectory is based on the rest framework. When using Servicesdirectory, you are guided through a series of links (usually URLs). Whenever you click or use a link, you can see a new page that contains more information about what is available on the server. This information is obtained using URLs through the rest framework.
When using the rest API, you first need to define the endpoint (Endpoint), which typically represents the directory of the server. For ArcGIS servers, the default endpoint is:
Http://
Description: Http://
Third, the ArcGIS REST API Framework
ArcGIS Rest is a structured framework. Some of these resources are directly responsive to the services themselves (resources), such as catalogs, maps, and layers, while others are the result of some operations (Operations), such as exporting a map image from a map resource, or getting a collection of query results for a layer. So the client can always get the performance of a resource from the server side, which is generally divided into two types of resources: resources (resource, which directly reflects the information of the service itself) Operations (operations, results obtained after some processing according to the resources of the service itself)
The following is the framework diagram for the entire Arcgisrest API
As you can see, the catalog is the root of the entire rest Apiurl hierarchical hierarchy. Below the root is the service published by this server, a total of 8 types of services: MAP service, Geocode Service, GP Service, Geometry Service, Image service, Network service , GeoData service, and Globe service. There are different operations and resources under each service, and the actions and access to these resources are through URLs.
Iv. Use of the ArcGIS REST API
1. Steps to use
Fundamentally speaking, Restapi is made up of web sites. The process of using the rest API is basically divided into four steps:
1) Build the request URL
A, determine the endpoint: Each GIS service has an endpoint. For example, the endpoint for a map service named Esri_census_usa under the Demographics folder on ArcGIS server sampleserver1.arcgisonline.com is:/http Sampleserver1.arcgisonline.com/arcgis/rest/services/demographics/esri_census_usa/mapserver.
B, determine the operation: different geographic information system services support different operations. Different operations will return different results. Map services can map out, click to view, find and generate KML. The output map can generate a map, and you can click Production to see if the map Service layer's attribute table is given.
C, determine the parameters: different operations require different parameters. For example, if you request a map picture, you need to provide the coordinate parameters of the surrounding corners of the map extent, which is the map coverage.
D. Determine the output format: The REST API supports many output formats, such as JSON,KMZ, images, and HTML. The important parameter to determine the output format is F. After the query string for the URL request, add "f=< your format >" to determine the output format. For example: f=html returns a data format of Html;f=json returned with a data format of Json;f=image returned in the format image and so on.
Let's build the URL we need in 4 steps above. In general, the format is as follows:
Http://{arcgis Server name}/arcgis/rest/services/{foldername}/{service name}/{service type}/{operation}? {{Parameter1}={somevalues}&{parameter2}={some values}&...&{parameter}={some values}}
As you can see, the entire URL request is divided into two parts, the first part is the endpoint of the service and the type of operation, that is, "?" The previous part; The second part is the query string, which is the request parameter, "?" The following section.
2) Send the request to ArcGIS Server
Submit URL requests to ArcGIS Server sending, you can send URL requests without programming. For example, simply enter the URL in the address bar of your Web browser, such as IE or Firefox. Each programming language uses a different way of making requests.
3) Accept the response from the server
Accepting the Arcgisserver response, ArcGIS server processes the request and returns the response to the client. For a synchronous work, the client waits for a response from the server. For a job, the server sends a job number to track the client's working status on a regular basis.
4) Resolve server response
The response of the ArcGIS Server REST Web service can be in a variety of formats, such as JSON,KML, pictures, and HTML. The client can determine whether the response succeeded or failed. If it fails, the client can determine the error message. If the response is successful, the client can parse the information needed for the response and use the information appropriately.
2. How to use
1) Non-programmed use
You can use a Web browser, arcgisserver javasccript map Browser (F=JSAPI), ArcGIS Explorer (F=NMF), ArcMap (f=lyr&v=9.3), Microsoft Virtual Earth (f=ve), Google Maps (f=gmaps), Google Earth to use the ArcGIS REST API.
The key to using RESTAPI with different tools is to set different F-parameters. Here is a demo that uses the rest API with a Web browser. I'm using the world map Service published on my own computer. To output a map image of our country in the browser, we need to specify the following parameters: Operation: Output Image f=image. Map bounding box (value format: West, south, east, north): bbox=72,3,135.5,53,5. Output image size: size=600,400 output format: f=image
Based on the above information, the URL is constructed as follows:
Http://localhost/ArcGIS/rest/services/World/MapServer/export?bbox=72,3,135.5,53,5&size=600,400&f=image
The result is as follows in the browser address bar output above URL:
2) Programming use
Here I use the rest API using the client language JavaScript with Ajax technology. The first layer of the World Service is read with the rest API's name and displayed on the popup dialog box.
Code
1 <! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> 2 3 < html xmlns =" http://www.w3.org/1999/xhtml "> 4 < head > 5 < title > REST API DEMO </title > 6 < script type = "text/javascript" language = "JavaScript" > 7 var request = NULL; 8//Create request object according to different browser 9 function createrequest () {One-try {] request = new XMLHttpRequest (); Crosoft) {try {*] request = new ActiveXObject ("Msxm12.xmlhttp"); (Othermicrosoft)-{try {* = new ActiveXObject ("Microsoft.XMLHTTP"); (faild) (+ = null), + ("Request object Failed") ("Create Request") (= null; The function sendrestrequest () is {createrequest (); var resturl = "Http://localhost/ArcGIS/rest/services/World /mapserver/0?f=json "; Constructed rest URL PNs Request.open ("GET", Resturl, True); The Request object initializes the connectionPick up Request.onreadystatechange = ProcessResponse; Sets the callback function after the server responds to the request. request.send (NULL); Send request to Server ProcessResponse () (request.readystate = = 4)//readiness State with 4 values of "1: Connection just be initialized;