Chilkat XML Supports XMLHTTP
The
ChilkatXml.HttpPost method provides client-side protocol support
for communication with HTTP servers. A client computer can use
this method to send an arbitrary HTTP request, receive the response,
and have Chilkat XML parse that response.
The request body is sent directly from the Chilkat XML object
and the response is parsed directly into the returned Chilkat
XML object. When combined with the support for Extensible Stylesheet
Language (XSL), this provides an easy way to send structured queries
to HTTP servers and efficiently display the results with a variety
of presentations.
Example
The following Visual
Basic example posts a document to an Active Server Pages (ASP)
page on a server and returns the result as a Chilkat XML document.
Dim xmlIn As ChilkatXml
Set xmlIn = New ChilkatXml
' Load the XML from the text box
' return 1 for success, 0 for failed.
Dim success As Long
success = xmlIn.LoadXml("<test><name>William</name></test>")
' Contents of xmlIn are passed in a parameter named "xml"
Dim xmlOut As ChilkatXml
Set xmlOut = xmlIn.HttpPost("http://www.myhost.com/test.asp")
' XmlResponse is an TextBox control on a VB form.
If (Not (xmlOut Is Nothing)) Then
XmlResponse.Text = xmlOut.GetXML()
End If
The
ASP page on the server loads the posted XML document, processes
the order, and builds a resulting XML document. It can be written
using ASP XML, or with MSXML. Here are
examples for both:
MSXML Example:
<%@ language=javascript %>
<% Response.Expires = -1000; // Load the posted XML document. var doc = Server.CreateObject("Msxml2.DOMDocument"); doc.load(Request); var result = Server.CreateObject("Msxml2.DOMDocument"); // Now process the order and build the result document. Response.ContentType = "text/xml"; result.save(Response);
%>
ASP XML Example:
<%
dim xmldoc
set xmldoc = Server.CreateObject("AspXml.AspXml")
' Get the incoming XML document from the ASP Request object.
' This is equivalent to "doc.load(Request)" when using MSXML
xmldoc.loadRequest()
dim child
set child = Server.CreateObject("AspXml.AspXml")
child.Tag = "info"
child.Content = "This is some information"
xmldoc.AddChildTree(child)
Response.ContentType = "text/xml"
Response.write(xmldoc.GetXml())
%>
About
Chilkat
|