Access SQL Server using HTTP

zhaozj2021-02-17  63

Access SQL Server using HTTP

You can use HTTP to access Microsoft® SQL ServerTM 2000. Before you can use HTTP to specify the query, you must first create a virtual root with the IIS virtual directory management utility used for SQL Server.

SQL Server HTTP access capabilities make you:

Specify SQL queries directly in the URL, for example: http: // Iisserver / nwind? SQL = SELECT * FROM CUSTOMERS FOR XML Auto & Root = root

Specifies that the FOR XML clause returns the result in the form of an XML document rather than a standard rowset. The root parameter identifies a single top element element. Template directly in the URL. The template is a valid XML document containing one or more SQL statements. The template allows you to put the data together to form a valid XML document, but it is not necessarily the case when specifying the query in the URL. For example: http: // Iisserver / nwind? Template = SELECT * FROM CUSTOMERS FOR XML AUTO

Specify a template file in the URL. Write a long SQL query in the URL. In addition, the browser may have restrictions on the amount of text that can be entered in the URL. To avoid these issues, you can write a template and store it in the file. The template is a valid XML document containing one or more SQL statements and XPath queries. Template files can be specified directly in the URL, for example: http: //iisserver/nwind/templatevirtualname/templatefile.xml

In the URL, TemplateVirtualName is a virtual name for the Template type created using the IIS virtual directory management utility used for SQL Server. The template file also deletes details from the user's database query to enhance security. In the virtual root directory (or its subdirectory) where the template file is stored in the registration database, the URL query processing service on the virtual root is deleted and only the SQL Server XML ISAPI is allowed to process files and return result sets, thereby strengthening security. Specifies the XPath query executed on the XML data simplification (XDR) architecture (also known as a mapping architecture) with annotation. From the concept, write XPath query to the mapping architecture and create a view using the Create View statement and write SQL query on the view, for example: http://iisserver/nwind/schemavirtualname/schemafile.xml/customer [@ Customerid = "Alfki" ]

In this URL:

SchemaVirtualName is a virtual name for the Schema type created using the IIS virtual directory management utility for SQL Server. Customer [@ Customerid = "ALFKI"] is an XPath query executed on schemafile.xml specified in this URL. Specify database objects directly in the URL. You can specify a database object (such as a table, and view) as part of the URL, specify xpath queries for the database object, for example: http: // Iisserver / nwind / dbObjectvirtualname / XPathQuery In this URL, DbobjectVirtualName is used for SQL Server IIS Virtual Directory Administrative utility creates virtual names of the DBObject type.

Note When an operation requiring resources (such as memory) is performed in the URL (create a temporary table and temporary stored procedure, declared cursor, execution sp_xml_prepaaredocument, etc.) must perform appropriate correspondence (such as Drop Table, Drop Procedure, DEAllocate cursor or Execute sp_xml_removedocument is released to release resources.

XML documentation and documentation

When performing templates or queries with root parameters, the result is a complete XML document with a single top element. For example, the following URL performs template:

http://iisserver/virtualroot/templatevirutalname/mytemplate.xml

Below is an example template file (MyTemplate.xml):

SELECT *

From customer

For XML Auto

marked in the template provides a single top element with the XML document.

You can specify a query directly in the URL. In this case, the root parameter specifies the top layer element in the document:

HTTP: // IISSERVER / VIRTUALROOT? SQL = SELECT * FROMERS for XML AUTO? root = root

If the root parameter is not used when writing the above query, an XML document clip will be returned (i.e., an XML document that is missing a single top element). This snippet has no title information. For example, the following URL will return to the document segment:

http: // Iisserver / VirtualRoot? SQL = Select * from customers for xml auto

When requesting an XML document, the byte order tag for identifying the document encoding type will be returned. The byte order tag is a standard byte order to identify the XML document encoding type. The XML analyzer uses this byte order to determine the document encoding type (such as Unicode). For example, byte order marking "oxff, 0xfe" identifies the document as Unicode. By default, the analyzer assumes that UTF-8 is a document encoding type.

The byte order mark is not returned when the XML fragment is requested, because byte order marking belongs to the XML document

The title, and there is no title in the XML fragment.

Use IIS virtual directory management utility for SQL Server

The appropriate virtual directory must be installed before using the HTTP to access the Microsoft® SQL ServerTM 2000 database. On a computer running Microsoft Internet Information Services (IIS), use the IIS Virtual Directory Management utility for SQL Server (in the SQL Server Tools "program, configure SQL XML Support in IIS,") defined and register The new virtual directory, the so-called virtual root. This utility indicates that IIS creates associations between new virtual directories and Microsoft SQL Server instances. The name of the IIS server and virtual directory must be specified as part of the URL. The information in the virtual directory (including login, password, and access) is used to establish a connection to a specific database and perform a query.

You can specify the URL:

Access database objects directly, such as a table. In this case, the URL will include a virtual name of the DBObject type. Execute a template file. The template is a valid XML document consisting of one or more SQL statements. When specifying a template file in the URL, the SQL command stored in the template file is executed. You can specify SQL queries directly in the URL, but considering security, it is not recommended. Execute an XPath query. Perform XPath queries for mapped map architecture files that are part of a part of the URL.

Virtual name

To make template files, mapping architecture files, or database objects (such as tables or views), you must create a virtual name for Template, Schema, and DbObject types. Specify a virtual name as part of the URL to perform a template file, perform XPath queries or directly access the database.

The virtual name type (Template, Schema, DBObject) specified in the URL is also used to determine the file type specified in the URL (template file or mapping schema file). For example, the following URL uses templates to access SQL Server databases:

http://iisserver/nwind/templatevirtualname/template.xml

TemplateVirtualName is a virtual name for the template type that identifies the specified file (Template.xml) is a template file.

转载请注明原文地址:https://www.9cbs.com/read-30703.html

New Post(0)