XML Related Technical Data _xml/rss

Source: Internet
Author: User
Tags error handling object model xml parser



XMLHTTP Technology:


----------------------------------------------------------


, database remote management technology





is an important link in the modern application of Internet based WAN is the remote monitoring of database. First of all, a brief review of the Internet Database Remote management technology development process and mode:





early through the preparation of Cgi-bin program modules for database remote management. But the cgi-bin is slow to run, maintenance is inconvenient, now has been basically discarded.





the use of Component object models (Component object model, COM) over the years has been very useful and effective. However, if you are using a Third-party server (the author's web site is built on a third party virtual host), the server side often does not allow users to register their own components for confidentiality or other business reasons.





in recent years by the Microsoft Company launched. NET platform and Sun Company's Java EE platform are very high-end database remote management and service platform. can provide high quality multi-layer (n-tier) application services.


among them,. NET (Simple Object access Protocol, SOAP) using Hypertext Transfer Protocol (hypertext Transfer Protocol, HTTP) and Extensible Markup Language (extensible Markup Language, XML technology enables communication services across systems (such as windows-linux) that have been widely accepted and used by developers. Many large applications, such as Enterprise resource planning (Enterprise resource Planning, ERP), are built on such a large platform.


but for small and medium-sized applications, such as the construction and maintenance of a Web site, this large-scale application platform is somewhat cumbersome, the cost is too large.





Microsoft, once a laggard in Internet technology and Java technology, is in the forefront of XML application development. The XMLHTTP protocol in her XML parser (MSXML) is a very convenient and practical customer/service communication conduit. The comprehensive use of XMLHTTP and ActiveX Data Objects (ActiveX Objects, ado/adox) can easily and conveniently implement remote database management.





This paper describes how to use XMLHTTP and ado/adox to make remote database management synthetically.





Second, database remote management system




The task flow of
database remote management is:


1, the client sends the database structure and the data query or the modification instruction to the server.


2, the server accepts and executes the instructions and returns the results to the client.


3, the client accepts and displays the results of the instruction execution returned by the server.




The two key
to realize remote management of database are:


1, the client and the server between the instruction upload and the results of the data channel, implemented by the XMLHTTP protocol.


2, the service end of the front and the database between the instruction transfer and results returned by the role of the middle-tier Ado/adox interface completed.

The use of
III and XMLHTTP





, as the name suggests, XMLHTTP is a Hypertext Transfer protocol that transmits XML-formatted data.





in fact, the XMLHTTP data transfer process is more flexible:


The instructions it uploads can be XML format data, or it can be a string, a stream, or an unsigned integer array. It can also be a parameter of a URL.


It can be a result of XML format data, or it can be a string, a stream, or an unsigned integer array.


details can be found at the end of the article link.




The process of
client calls to XMLHTTP is simple, with only 5 steps:


1, create XMLHTTP object


2, open the connection with the service side, at the same time define instructions to send the way, the Service page (URL) and request permissions.

The
client opens a connection to the Service Web page of the server through the Open command. As with normal HTTP instructions, you can use the "get" method or the "POST" method to point to the Service Web page of the server.


3, send instructions.


4, waits and receives the processing result returned by the service side.


5, Release XMLHTTP Object





xmlhttp Method:


Open Bstrmethod, bstrURL, Varasync, Bstruser, Bstrpassword


bstrmethod: Data transfer mode, i.e. get or post.


bstrurl: URL of the Service Web page.


Varasync: Synchronous execution. The default is true, which is synchronous execution, but can only be implemented synchronously in the DOM.


is typically set to false in an application, that is, asynchronous execution.


bstruser: User name, can be omitted.


bstrpassword: User password, can be omitted.





Send varbody


varbody: Instruction set. can be XML format data, or it can be a string, a stream, or an unsigned integer array. You can also omit the instruction by substituting the URL parameter for the open method.





setrequestheader Bstrheader, Bstrvalue


bstrheader:http Header (header)


Bstrvalue:http header (header) value


if the open method is defined as post, you can define a form to upload:


Xmlhttp.setrequestheader "Content-type", "application/x-www-form-urlencoded"





XMLHTTP Properties:


onreadystatechange: Gets the event handle that returns the result in the synchronous execution mode. Can only be invoked in the DOM.


responsebody: The result returns an array of unsigned integers.


Responsestream: The result is returned to the IStream stream.


ResponseText: The result is returned as a string.


Responsexml: Results are returned as XML format data.








Here is an example of an application in the source program for the attachment in this article:


Function GetResult (URLSTR)


Dim xmlHttp


Dim retstr





Set xmlHttp = CreateObject ("Msxml2.xmlhttp") ' Create object


On Error Resume Next ' Error handling


Xmlhttp.open "Post", Urlstr, False ' opens the connection by post and executes asynchronously.


Xmlhttp.setrequestheader "Content-type", "application/x-www-form-urlencoded" ' Upload form


xmlhttp.send ' send instructions





If Err.Number = 0 Then ' If the connection is correct


retstr = Xmlhttp.responsetext ' waits and gets the result string returned by the server


Else


retstr = "Url not found" otherwise an error message is returned


End If


Set xmlHttp = Nothing ' Frees object


GetResult = Retstr ' returns results


End Function




The
GetResult () function takes the URL parameter of a service Web page and places the uploaded instruction on the parameters following the URL, such as:


urlstr = "server.asp?cmd=" & cmd & "&db=" & DB & "table=" & Table


cmd: Execution methods, such as queries, modifications, deletions, and so on.


DB: Server-side database name


table: Service-Side Tables name





then submits the instruction, waits for and receives the returned processing result. The result is returned as a string.





is finally processed by the function caller and displays the result.





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.