In many situations, and particularly in the case of the Commerce Interchange Pipeline, it is useful to execute a pipeline from within an executable application, rather than within the context of an ASP file.
To do this, you create an OrderPipeline object, and request an IOrderPipeline interface pointer on that object. Then, you use the IOrderPipeline interface pointer to call the LoadPipe and Execute methods.
The following sample code illustrates this process:
// At the top of the file: necessary include directives.
#include "mspu_guids.h"
#include "pipeline.h"
// In the body of the function in which you execute the pipeline.
IOrderPipeline *pOrderPipeline = NULL;
long lErrorLevel = OPPERRORLEV_WARN; // Tolerate warnings.
WCHAR *pwszPCF = L"c:\\Microsoft Site Server\\Sites\\Commerce\\Market\\SendHTTP.pcf";
HRESULT hResult;
// Initialize the COM library.
hResult = CoInitialize(NULL);
if(FAILED(hResult)){
AfxMessageBox(IDS_CANT_INIT_COM, MB_OK);
return;
}
hResult = CoCreateInstance(CLSID_COrderPipeline, NULL, NULL, CLSCTX_INPROC_SERVER, IID_IOrderPipeline, (void**)&pOrderPipeline);
if(FAILED(hResult)){
AfxMessageBox(IDS_CANT_CREATE_PIPELINE, MB_OK);
return;
}
hResult = pOrderPipeline->LoadPipe(pwszPCF);
if(FAILED(hResult)){
AfxMessageBox(IDS_CANT_LOAD_PIPE, MB_OK);
pOrderPipeline->Release();
pOrderPipeline = NULL;
return;
}
hResult = pOrderPipeline->Execute(0, pDispOrder, NULL, 0, &lErrorLevel);
This example assumes that the pDispOrder variable represents a valid IDispatch interface on the Dictionary or OrderForm object that contains the order information.