Partager via


WMRMMetering.GetMeteringData

banner art

Previous Next

WMRMMetering.GetMeteringData

The GetMeteringData method retrieves data from the metering challenge as a WMRMMeteringData object.

Syntax

  WMRMMeteringData = WMRMMetering.GetMeteringData

Parameters

This method takes no parameters.

Return Values

If the method succeeds, it returns a WMRMMeteringData object containing the metering data. If it fails, it returns a number in the error object.

Remarks

When retrieving the data as a WMRMMeteringData object, you can access the data programmatically. The data is organized into a collection of WMRMMeteringContent objects, allowing you to access metering data by content. Each content object is organized into a collection of WMRMMeteringAction objects, which breaks down the metering data by type of action and by count.

You can also retrieve metering data as an XML string by using the WMRMMetering.GetMeteringDataAsXml method.

Example Code

'"""""""""""""""""""""""""""""""""""""""""""""""""""""
' Declare variables.
'""""""""""""""""""""""""""""""""""""""""""""""""""""" 
Dim MObj                    ' WMRMMetering object
Dim MDataObj                ' WMRMMeteringData object
Dim MContentCollObj         ' WMRMMeteringContentCollection object
Dim MContentObj             ' WMRMMeteringContent object
Dim MActionCollObj          ' WMRMMeteringActionCollection object
Dim MActionObj              ' WMRMMeteringAction object

Dim MeterChallenge          ' Metering challenge from the client
Dim MASPrivateKey           ' Private key of the metering aggregation service
Dim MeterCert               ' Metering certificate
Dim MeterXMLString          ' Metering data in XML format
Dim MeterID                 ' Metering ID
Dim TransID                 ' Transaction ID
Dim ContentCollLength       ' Number of items in the content collection
Dim ContentKeyID            ' Key ID for a content item
Dim ActionCollLength        ' Number of items in the action collection
Dim ActionName              ' Action name
Dim ActionValue             ' Action count
Dim MeterResponseString     ' Metering response string
Dim x, y                    ' Counters

'"""""""""""""""""""""""""""""""""""""""""""""""""""""
' Set variables.
'"""""""""""""""""""""""""""""""""""""""""""""""""""""
MeterChallenge = "<Replace with a metering challenge from the client>"
MeterCert = "<Replace with your metering certificate>"
MASPrivateKey = "<Replace with the private key for your service>"

'"""""""""""""""""""""""""""""""""""""""""""""""""""""
' Extract metering data an a WMRMMeteringData object and as an XML string.
'"""""""""""""""""""""""""""""""""""""""""""""""""""""
Set MObj = Server.CreateObject("WMRMObjs.WMRMMetering")
MObj.ServerPrivateKey = MASPrivateKey
MObj.Challenge = MeterChallenge
Set MDataObj = MObj.GetMeteringData
Set MeterXMLString = MObj.GetMeteringDataAsXml
MeterID = MDataObj.MeteringId
TransID = MDataObj.TransactionId

'"""""""""""""""""""""""""""""""""""""""""""""""""""""
' Retrieve the collection of content items.
'"""""""""""""""""""""""""""""""""""""""""""""""""""""
Set MContentCollObj = MDataObj.ContentCollection
ContentCollLength = MContentCollObj.length

'"""""""""""""""""""""""""""""""""""""""""""""""""""""
' Retrieve the key ID and action data for each content item.
'"""""""""""""""""""""""""""""""""""""""""""""""""""""
For x = 0 To (ContentCollLength - 1)
    Set MContentObj = MContentCollObj.item(x)
    ContentKeyID = MContentObj.KeyID

    '"""""""""""""""""""""""""""""""""""""""""""""""""""""
    ' Retrieve the collection of actions for the current content item.
    '"""""""""""""""""""""""""""""""""""""""""""""""""""""
    Set MActionCollObj = MContentObj.Actions
    ActionCollLength = MActionCollObj.length

    '"""""""""""""""""""""""""""""""""""""""""""""""""""""
    ' Retrieve each action and its value.
    '"""""""""""""""""""""""""""""""""""""""""""""""""""""
    For y = 0 To ActionCollLength - 1
        Set MActionObj = MActionCollObj.item(y)
        ActionName = MActionObj.Name
        ActionValue = MActionObj.Value
    Next
Next

'"""""""""""""""""""""""""""""""""""""""""""""""""""""
' Generate the metering response.
'""""""""""""""""""""""""""""""""""""""""""""""""""""" 
MObj.MeteringCertificate = MeterCert
MeterResponseString = MObj.GetMeteringResponse

Requirements

Version: Windows Media Rights Manager 10 SDK or later

Reference: wmrmobjs 1.0 Type Library

Library: wmrmobjs.dll

Platform: Windows Server 2003

See Also

Previous Next

© 2007 Microsoft Corporation. All rights reserved.