SQL Anywhere 11 (Panorama) review guide Part IX_Mssql series tutorials

Source: Internet
Author: User
Tags data structures dba html page json port number

The routine can pass throughHttp://www.sybase.com/files/Technical_Documents/PanoramaRevGuide.zipDownload
In this document, SQL Anywhere 11 may appear elsewhere as SQL Anywhere Panorama.

JSON Web Service
JASON (JavaScript Object Notation) is a simple and lightweight data exchange format, which is very suitable for displaying and exchanging data structures. Although JSON is independent of programming languages, JavaScript is used in most cases because JSON objects can be easily rebuilt and used in data structures. SQL Anywhere 11 uses the built-in HTTP server to support web service requests to return results in JSON format. The result set is returned through an array of key-value pairs. Each key represents a column in the result set.

JSON Web Service routine
This routine uses the SQL Anywhere demo database to return the employees list in JSON format and display it in the browser. The JSON list is used, and the employee name is displayed. The JSON list of Employees is obtained by an AJAX request returned to the server. In this example, the SQL Anywhere built-in HTTP server is used and a browser that supports JavaScript is required.

1. Make sure that no database server is running. If yes, disable it.
2. Navigate to the JSON Directory of the routine in the command line.
3. Run the following command to copy the SQL Anywhere 11 demo database to the current directory:

Copy "% SQLANYSAMP11 % demo. db ".

4. Start the HTTP server of the demo database. Run the following command to specify the port number of the HTTP server as 8080 (if necessary, specify another port ):

Dbsrv11 demo. db-xs "http (port = 8080 )"

5. Start Interactive SQL and connect to the demo database:

Dbisql-c "eng = demo; uid = DBA; pwd = SQL"

6. Create a stored procedure for reading HTML pages from the current directory. Copy the following code to Interactive SQL and press F5 to run it:

Create procedure sp_root ()
BEGIN
CALL dbo. sa_set_http_header (''content-type'', ''text/html '');
SELECT xp_read_file ('json.html '');
END;

7. Create a root web service and return to the HTML page. Copy the following code to Interactive SQL and press F5 to run it:

Create service "root"
TYPE ''raw''
AUTHORIZATION OFF
USER DBA
As call sp_root ();

8. Create an employees webservice, which is called by json.html. Copy the following code to Interactive SQL and press F5 to run it:

Create service "employees"
TYPE ''json''
AUTHORIZATION OFF
USER DBA
As select * FROM "Employees ";

9. Open the browser and browse http: // localhost: 8080/demo /.
10. Click "Get Employees" to initiate an AJAX request to the emplyees web service. The employees list in the demo database is displayed.

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.