Typical C++ Usage
LPCWSTR wszRequest = L"<request>\n" +
L" <data>\n" +
L" <organizations>\n" +
L" <organization name=\"tailspintoys.com\"/>\n" +
L" </organizations>\n" +
L" </data>\n" +
L" <context>\n" +
L" <clientContext clientTransactionId=\"53367B03-63D3-44ae-B8AD-C1E57E876E6C\"/>\n" +
L" </context>\n" +
L"</request>";
IProvQueue * pProvQueue = NULL;
BSTR bstrRequest = ::SysAllocString(wszRequest);
BSTR bstrNamespace = ::SysAllocString(L"Test Namespace");
BSTR bstrProcedure = ::SysAllocString(L"Write Request");
BSTR bstrQueueID = NULL;
HRESULT hr = E_OUTOFMEMORY;
if(bstrRequest && bstrNamespace && bstrProcedure)
{
// Create queue manager client:
hr = CoCreateInstance(CLSID_ProvQueueClient, NULL, CLSCTX_ALL, IID_IProvQueue, (void**)(&pProvQueue));
if(hr == S_OK)
{
hr = pProvQueue->SubmitRequest(bstrRequest, bstrNamespace, bstrProcedure, FALSE, &bstrQueueID);
pProvQueue->Release();
}
}
// Get the error description in the case of error
if(FAILED(hr))
{
IErrorInfo* pErrInfo = NULL;
if(::GetErrorInfo(0, &pErrInfo) == S_OK && pErrInfo)
{
pErrInfo->GetDescription(&bstrQueueID);
pErrInfo->Release();
}
}
// Show the results
MessageBoxW(NULL, bstrQueueID ? bstrQueueID : L"Unknown error occured", L"Queued request results", MB_OK);
// Clean up
::SysFreeString(bstrRequest);
::SysFreeString(bstrNamespace);
::SysFreeString(bstrProcedure);
::SysFreeString(bstrQueueID);