Installing the XMLRPCClient object
Place the xmlrpc.dll file in the desired directory. Execute the following command from the directory where the file was copied:
regsvr32 xmlrpc.dll
Creating an instance of the Convert object
JScript example:
var rpc = Server.CreateObject
("XMLRPC.Convert");
VBScript example:
Dim rpc
Set rpc = Server.CreateObject ("XMLRPC.Convert")
Methods
Convert(Value, NewType)
Converts a variant from on type to another type.
Value - The variant to convert.
NewType - The type of variant to convert to. Can be one of the following:
vtEmpty - Uninitialize variant.
vtNull - Null valued variant.
vtI2 - 16 bit signed integer.
vtI4 - 32 bit signed integer.
vtR4 - 32 bit floating point value.
vtR8 - 64 bit floating point value.
vtDate - Date time value.
vtBstr - String value.
vtBool - Boolean value.
vtI1 - 8 bit signed integer.
vtUI1 - 8 bit unsigned integer.
vtUI2 - 16 bit unsigned integer.
vtUI4 - 32 bit unsigned itneger.
vtI8 - 64 bit signed integer.
vtUI8 - 64 bit unsigned integer.
Returns a variant of the specified type.
This method call can be useful for coercing a value to a specified type in scripting enviroments that do not allow variables to take on all of the XML-RPC supported types.
Example:
var rpc = Server.CreateObject
("XMLRPC.XMLRPCClient");
var cnv =
Server.CreateObject ("XMLRPC.Convert");
var retval =
rpc.Call("http://someurl.com/RPC2", "AMethodThatWantsAnInt", cnv("5",
vtI4));
Creating an instance of the XMLRPCClient object
JScript example:
var rpc = Server.CreateObject ("XMLRPC.XMLRPCClient");
VBScript example:
Dim rpc
Set rpc = Server.CreateObject ("XMLRPC.XMLRPCClient")
Methods
Call([url], MethodName, [Parameters])
Executes an XML-RPC method.
url - The url where the method is located. If this parameter is omitted, then the value of the url property is used.
MethodName - The name of the method to execute.
Parameters - The parameters required by the method.
Returns the result of the XML-RPC method call. If the return value is single valued, then the result is a single value. If the return value is an array, then the return value is an array. If the return value is a struct, the return value is a Dictionary object that contains a Key/Value pair for each of the items in the struct. Since XML-RPC allows for unlimited nesting of arrays and structs, array elements may contain arrays or Dictionary objects themselves. Similarly, Dictionary objects may contains values that are Dictionary objects or arrays.
When invoking this method from a scripting environment, it is not necessary to create an array to hold the parameters. The parameters can merely be passed as any other parameter [e.g. the following is possible form JScript:
var retval = rpc.Call("http://someurl.com/RPC2", "AMethod", "See ma, no ugly arrays needed", 34.5, true);
VBCall(Results, [url], MethodName, [Parameters])
Executes an XML-RPC method.
Results - A place holder for the return value from the XML-RPC method.
url - The url where the method is located. If this parameter is omitted, then the value of the url property is used.
MethodName - The name of the method to execute.
Parameters - The parameters required by the method.
Places the result of the XML-RPC method call into the variable specified in Results. If the return value is single valued, then the result is a single value. If the return value is an array, then the return value is an array. If the return value is a struct, the return value is a Dictionary object that contains a Key/Value pair for each of the items in the struct. Since XML-RPC allows for unlimited nesting of arrays and structs, array elements may contain arrays or Dictionary objects themselves. Similarly, Dictionary objects may contains values that are Dictionary objects or arrays.
When invoking this method from a scripting environment, it is not necessary to create an array to hold the parameters. The parameters can merely be passed as any other parameter [e.g. the following is possible form VBScript:
rpc.VBCall(retval, "http://someurl.com/RPC2", "AMethod", "See pa, no ugly arrays needed", 34.5, true)
The purpose of creating a secondary method that performs essentially the same action as the Call method is to overcome a limitation in VBScript. In VBScript, if a method returns an object, the Set keyword is needed for assignment.
ToBytes(Data)
Converts Data to an array of bytes.
Data - The data to be converted. If this value is a string, the individual characters of the string will be converted to bytes on a character by character basis. If the value is a scripting file object, then the contents of the file are converted.
Returns an array of bytes representing the original data.
This method is primarily used in conjunction with the Call or VBCall methods to force a parameter to be encoded as base64.
EncodeBase64(Data)
Converts an array of bytes to a base64 character string.
Data - The data to be converted.
Returns a string representing the original data in base64 form.
This method is used internally by Call and VBCall but was exposed because of its usefulness in other applications.
DecodeBase64(Data)
Converts a base64 character string to an array of bytes.
Data - The data to be converted.
Returns an array of bytes representing the original data.
This method is used internally by Call and VBCall but was exposed because of its usefulness in other applications.
Properties
url
A string specifying the url to be used by Call and VBCall if the url parameter is not specified when call these methods. Not implemented yet.
OverrideCharset
A string specifying the character set that the server is encoding the response data in. This is useful if the server is not encoding in UTF-8 but doesn't specify which character set it is using (e.g. Frontier Web server on the Mac).
The only value supported for this property is macintosh to represent the Mac character set.
HyphensInDateTime
A boolean specifying whether or not to insert hyphen between the year, month, and day fields when sending an ISO8601 date/time value. Setting the property to true indicates that hyphens are to be inserted.
License
The XML-RPC COM object is released as freeware and will be placed under GPL once the server portion is completed.