<?xml version="1.0" ?>
<XIRServices>
<service id="testservice" ProgID="XIRTestServer.CTest"
Method="TestCall" CallType="1">
<param type="3"/>
<param type="8"/>
<param type="8"/>
<param type="9"/>
<retval type="9"/>
</service>
<service id="GetEmployees" ProgID="XIRTestServer.CTest"
Method="GetEmployees" CallType="1">
<retval type="9"/>
</service>
<service id="GetEmployeeName" ProgID="XIRTestServer.CTest"
Method="GetEmployeeName" CallType="1">
<param type="8"/>
<retval type="8"/>
</service>
</XIRServices>
In addition to the component ProgId and method name, the XIR
server needs the actual values of all input parameters. We need to
choose a data structure to pack and send all this information. XML
offers a good medium for storing and sending this information since
it provides a tree structure within a simple string. This string can
then be easily sent over HTTP using POST.
To actually send the document, you can use the XMLHttpRequest
(Microsoft.XMLHTTP) object part of the MSXML parser. Using this
component you can send an HTTP request complete with headers and
receive the response in an XML DOM document. You can also send HTTP
request headers and choose to send the request synchronously or
asynchronously. You will see some code a little later showing how to
post an HTTP request sending along an XML document and the relevant
cookies. It is important to send cookies if you are using ASP
sessions. This is because sessions are tracked by placing a cookie on
the client machine; therefore sending a request without the session
cookie would mistakenly cause a new session to be created.
Sending data in XML format works well for simple data types that
can be easily converted to strings and embedded in XML, but what
about other data types such as ADO Recordsets and objects in general?
You still have to convert these to string somehow. Fortunately, ADO
2.5 allows you to serialize a Recordset into a string and save it to
a Stream object. You can then read this string out of the Stream
object, embed it in the request XML and send it over to the other
side where a new Recordset is created and the data is read back into
it. It is worth mentioning that the Recordset saves itself to a
string containing an XML document, however this is just a coincidence
and has nothing to do with our use of XML.
Finally, to send objects using XIR, you make the objects
themselves do the work for you. Any object that is being sent using
XIR must implement the IXIRPersistXML interface. The interface has
two methods: LoadXML(sXML As String) and SaveXML() As String. As
their names imply, these methods can be used to load object state
from, and save it back to XML. You use SaveXML to stream out an
object to a string, embed that string into the request XML, send it
over to the other side, then rehydrate it using LoadXML. It is up to
the object itself to provide proper implementation of these two
methods so you need not worry about it (unless you are also
implementing the object!).