Microsoft KB Archive/199299

= How to Instantiate and Call a Commerce Interchange Pipeline Using C++ =

Article ID: 199299

Article Last Modified on 7/18/2001

-

APPLIES TO


 * Microsoft Site Server 3.0 Standard Edition

-



This article was previously published under Q199299



SUMMARY
The following sample code can be used to instantiate and call a Commerce Interchange Pipeline:


 * 1) include "windows.h"
 * 2) include "ole2.h"
 * 3) include "pipeline.h"
 * 4) include "commerce.h"
 * 5) include "initguid.h"
 * 6) include "mspu_guids.h"

HRESULT SampleExecutePipe {

HRESULT hr = S_OK;

IPipeline*     pPipeline = NULL; IDictionary*   pRootDictionary = NULL; IDictionary*   pChildDictionary = NULL; IDispatch*     pdispChildDictionary = NULL; BSTR           bstrP = NULL; BSTR           bstrStringName = NULL; BSTR           bstrChildName = NULL; long           lErrors = 0; VARIANT        vChild; VARIANT        vString; VariantInit( &vChild ); VariantInit( &vString ); // build up the dictionary structure showing a root dictionary //     containing a child dictionary //         containing a string to process //    // create the root //    hr = CoCreateInstance( CLSID_CDictionary, NULL, CLSCTX_INPROC_SERVER,                            IID_IDictionary, (LPVOID*) &pRootDictionary); if (FAILED(hr)) goto Error; // create the child //    hr = CoCreateInstance( CLSID_CDictionary, NULL, CLSCTX_INPROC_SERVER,                            IID_IDictionary, (LPVOID*) &pChildDictionary); if (FAILED(hr)) goto Error; // add the string to process to the child //    bstrStringName = SysAllocString( L"input_string" ); // it will go here if (!bstrStringName) goto Error; bstrP = SysAllocString( L"Interesting text to process." ); if (!bstrP) goto Error; vString.vt = VT_BSTR; vString.bstrVal = bstrP; hr = pChildDictionary->put_Value( bstrStringName, vString ); // attach the child to the root -- as a IDispatch //    //hr = pChildDictionary->QueryInterface(IID_IDispatch,    //                         (LPVOID*) &pdispChildDictionary); hr = pChildDictionary->QueryInterface( IID_IUnknown,                               (LPVOID*) &pdispChildDictionary); if (FAILED(hr)) goto Error; vChild.vt = VT_UNKNOWN | VT_BYREF; vChild.ppunkVal = &pdispChildDictionary; bstrChildName = SysAllocString( L"child_container" ); // it will go here if (!bstrChildName) goto Error; hr = pRootDictionary->put_Value( bstrChildName, vChild ); // create/load pipeline //    hr = CoCreateInstance( CLSID_CMtsPipeline, NULL, CLSCTX_INPROC_SERVER,                         IID_IPipeline, (LPVOID*) &pPipeline); if (FAILED(hr)) goto Error; //ERROR //hr = pPipeline->LoadPipe( L"c:\filename.pcf" ); hr = pPipeline->LoadPipe(bstrPipeFile); if (FAILED(hr)) goto Error; // process the root/child/string //    hr = pPipeline->Execute( 1, pRootDictionary, NULL, 0, &lErrors );

if (FAILED(hr)) goto Error; if (lErrors > OPPERRORLEV_SUCCESS) hr = E_FAIL; // consume the results -- stored in the root dictionary here //  Error:

if (bstrP) pChildDictionary->Release; if (pdispChildDictionary) pdispChildDictionary->Release; if (pChildDictionary) pChildDictionary->Release; if (pRootDictionary) pRootDictionary->Release; if (pPipeline) pPipeline->Release; if (bstrP) SysFreeString( bstrP ); if (bstrStringName) SysFreeString( bstrStringName ); if (bstrChildName) SysFreeString( bstrChildName ); return hr; }



MORE INFORMATION
Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs.

Keywords: kbhowto kbfaq KB199299

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.