Microsoft XML Core Services (MSXML) 5.0 for Microsoft Office - Digital Signatures

createSAXProxy Method

[This feature was first implemented for MSXML 5.0.]

Creates and returns a SAX proxy object that can be used by the setReferenceData method to assign a SAX stream as the new data source of the signature object or template.

[JScript]

Script Syntax

var SAXProxy = objIXMLDigitalSignature.createSAXProxy();
[Visual Basic]

Visual Basic Syntax

Set SAXProxy = objIXMLDigitalSignature.createSAXProxy();
[C/C++]

C/C++ Syntax Using Smart Pointers

IUnknownPtr SAXProxy = objIXMLDigitalSignature.createSAXProxy();

C/C++ Syntax

HRESULT createSAXProxy(IUnknown ** SAXProxy)

Parameters

SAXProxy
This is a pointer to the resultant SAX proxy object in C/C++ applications not using smart pointers. In Visual Basic, scripting languages, and C/C++ with smart pointers, this is SAX proxy object itself.

Return Values

S_OK
The method succeeded, and the SAX proxy object returned.
E_FAIL
The method failed, and the SAXProxy parameter returns NULL.

Remarks

To assign a SAX stream as the new data source of a signature object, you must first use this method to create a SAX proxy object. Then, connect this object to a SAX reader from which the stream originates.

The SAX proxy object supports the ISAXContentHandler, ISAXLexicalHandler, ISAXErrorHandler, IVBSAXContentHandler, IVBSAXLexicalHandler, IVBSAXErrorHandler interfaces and parses the data stream into XML documents or nodes. It serves as a content handler, error handler, and lexical handler between the SAX reader and the signature object.

The following is a general workflow for signing or verifying XML data from a SAX stream:

  1. Create a SAX proxy object using this method.
  2. Call the setReferenceData method to set this proxy object as the new data source of a signature object.
  3. Create a SAX reader.
  4. Set the SAX proxy object as the content handler of the SAX reader,
  5. Set the SAX proxy as the lexical handler to process comments, if desired.
  6. Set the SAX proxy as the error handler to catch exceptions, if desired.
  7. Call the parse method or the parseURL method on the SAX reader to start feeding data into the signature object through the SAX proxy.

Do not reuse the SAX proxy object in a single signing and/or verification. To work with multiple SAX sources, create a proxy object for each source. Any errors, including warnings, will interrupt the SAX stream and prevent the data from being signed or verified.

A SAX proxy object can be used to improve the performance of an application when it is used to sign and/or verify data from a remote location multiple times. In this case, you can first download the data to a local store, then access the local copy of the data with the help of a SAX proxy object. This saves repeated round trips for data retrieval across the network.

Example

This example illustrates how to use the createSAXProxy method and the setReferenceData method to use an XML data file in the local file system as the new data source of a signature template. It uses two resource files: a signature template (signature_template.rsa.xml) and a data file to be signed (test.xml). The signature template contains simple text data ("Hello, World!") embedded as the content of a <ds:Object> element. This simple text data is signed as usual. In contrast, test.xml is signed with the help of a SAX proxy object.

We've provided source files for the sample in three languages: JScript, Visual Basic, and C++. The output is the same in each language.

Applies To

IXMLDigitalSignature | IXMLDigitalSignatureEx

Versioning

MSXML 5.0 and later

To view reference information for Visual Basic, C/C++, or Script only, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

setReferenceData Method | ISAXXMLReader Interface