The Dispatcher Component

The heart of 4S4C is the dispatcher, this component does the work of taking the text of the SOAP request, parsing it, creating the correct component, building the call stack, making the method call, and finally building the response text.

The component uses the SAX2 Parser from Apache's Xerces-C for parsing the request XML. The call stack and method call is all driven using the type library definition of the interface.

The HTTP and SMTP listener are simple pieces of code which grab the request, call the dispatcher and return the results, the ASP listener is 13 lines of VBScript, whilst the SMTP listener is about 90 lines of C++. If you wanted to support other transports besides those provided you should have little trouble writing the transport code.

Calling the dispatcher

To write your own listener, you'll need to call the dispatcher, the dispatcher itself implements 2 interfaces, IDispatcher & IDispatcher2.
interface IDispatcher : IUnknown
{
    HRESULT Go (    [in] BSTR soapRequestXML, 
                    [in] BSTR ProgID, 
                    [in] BSTR InterfaceIID, 
                    [out,retval] BSTR * soapResponseXML ) ;
};

interface IDispatcher2 : IDispatcher
{
    HRESULT ExecuteWithConfig ( [in] BSTR soapRequestXML, 
                                [in] IConfigFactory * pConfig, 
                                [out,retval] BSTR * soapResponseXML ) ;
};
IDispatcher::Go is the pre 1.2 method for invoking requests, it takes the text of the SOAP request, along with the Prog-ID and stringified IID of the component to invoke. IDispatcher2::ExecuteWithConfig is the new method for invoking SOAP requests from the configuration file. IDispatcher::Go continues to be available for use by existing pre 1.2 listeners. New listeners should use the ExecuteWithConfig method.
The ConfigFactory component handles parsing the config.xml file and caching the results. The dispatcher will call the GetConfigForURI method on the IConfigFactory object to obtain information about which object and interface to make the call on.


<<< Using the SMTP Listener      >>> Tutorial