IWMSCacheItem::get_OriginUrl

banner art

Previous Next

IWMSCacheItem::get_OriginUrl

The get_OriginUrl method retrieves the full URL for the cached content.

Syntax

  HRESULT get_OriginURL(
  
  BSTR*
  
  OriginUrl
  
  );

Parameters

OriginUrl

[out] BSTR that contains the URL.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code Number Description
E_OUTOFMEMORY 0x8007000E There is insufficient memory to complete the function.
E_POINTER 0x80004003 OriginUrl is a NULL pointer argument.

Remarks

The full URL is returned. The URL that is returned by this method is the same URL that is used by the client to request content.

Example Code

#include <windows.h>
#include <atlbase.h>    // Includes CComBSTR and CComVariant.
#include "wmsserver.h"

// Declare variables and interfaces.
IWMSServer                  *pServer;
IWMSPlugins                 *pPlugins;
IWMSPlugin                  *pPlugin;
IWMSCacheProxyPlugin        *pCacheProxyPlugin;
IWMSCacheItems              *pCacheItems;
IWMSCacheItem               *pCacheItem;

HRESULT         hr;
CComVariant     varIndex;
CComBSTR        bstrOriginURL;
long            lCount;

// Initialize the COM library and retrieve a pointer
// to an IWMSServer interface.
hr = CoInitialize(NULL);
hr = CoCreateInstance(CLSID_WMSServer,
                      NULL,
                      CLSCTX_ALL,
                      IID_IWMSServer,
                      (void **)&pServer);
if (FAILED(hr)) goto EXIT;

// Retrieve a pointer to an IWMSPlugins interface
// that contains cache proxy plug-ins.
hr = pServer->get_CacheProxy(&pPlugins);
if (FAILED(hr)) goto EXIT;
hr = pPlugins->get_Count(&lCount);
if (FAILED(hr)) goto EXIT;

// Retrieve the IWMSPlugin interface for the
// first cache proxy plug-in.
varIndex = 0;
hr = pPlugins->get_Item(varIndex, &pPlugin);
if (FAILED(hr)) goto EXIT;
// Retrieve a pointer to the IWMSCacheProxyPlugin interface.
hr = pPlugin->QueryInterface(IID_IWMSCacheProxyPlugin,
                            (void **)&pCacheProxyPlugin);
if (FAILED(hr)) goto EXIT;

// Retrieve a pointer to the IWMSCacheItems interface,
// and retrieve the count of cache items.
hr = pCacheProxyPlugin->get_CacheItems(&pCacheItems);
if (FAILED(hr)) goto EXIT;
hr = pCacheItems->get_Count(&lCount);
if (FAILED(hr)) goto EXIT;

// Retrieve the origin address of each cache item.
for (long x = 0; x < lCount; x++) {
    varIndex = x;
    hr = pCacheItems->get_Item(varIndex, &pCacheItem);
    if (FAILED(hr)) goto EXIT;
    hr = pCacheItem->get_OriginUrl(&bstrOriginURL);
    if (FAILED(hr)) goto EXIT;

    // Release temporary COM objects.
    pCacheItem->Release();
}

EXIT:
    // TODO: Release temporary COM objects and uninitialize COM.

Requirements

Header: wmsserver.h.

Library: WMSServerTypeLib.dll.

Platform: Windows ServerĀ 2003 family, Windows ServerĀ 2008 family.

See Also

Previous Next