# MTSessionSet

The MTSessionSet class allows you to create and store sessions together, and later submit them together, as a batch, to the server. The client should use the CreateSession method to create and add sessions to the collection, and the Close method to submit them all at once.

| Note | To use Authentication/Authorization functionality, you must use session sets; if you meter using only sessions, then you cannot use Auth/Auth.

## Program ID

MetraPipeline.MTSessionSet.1

## MTSessionSet Methods

Close | Sends all sessions in the set to the server.
CreateSession | Creates a session as part of the set
FromXML | Reconstructs the object state from XML
GetSessionSetID | Retrieves the unique ID assigned to this set.
GetLastError | Returns the error code for the last call, if any.
GetLastErrorObject | Returns a MTMeterError object that holds information about the last error.
ToXML | Converts a session into its XML representation.

## MTSessionSet Properties

transactionID | Gets/sets the distributed transaction ID that this set belongs to.
SecurityContext | Gets/sets the security context for the caller or actor.
SessionContext | Gets/sets the SessionContext property, which holds the caller's serialized session context.
SessionContextUserName | Gets/sets the username for the session.
SessionContextPassword | Gets/sets the password for the session.
SessionContextNamespace | Gets/sets the namespace for the session.

## Example

Example to be provided in a future release of this online help system.

# Method Detail

## CreateSession

Creates a session as part of the set.

### Visual Basic Syntax

Sub CreateSession(serviceName As Char) As MTSession

### C++ Syntax

HRESULT CreateSession([in] const char * serviceName, [out, retval] * MTSession);

### Arguments

serviceName

Service definiton corresponding to this set; must match the name of a service defined on the metering server.

### Return Value

Returns a pointer to a new MTSession instance.

## GetSessionSetID

Retrieves the unique ID assigned to this set.

### Visual Basic Syntax

Sub GetSessionSetID(sessionSetID As Char)

### C++ Syntax

HRESULT GetSessionSetID(char * sessionSetID);

### Arguments

sessionSetID

Pointer to a character buffer that will hold the session ID and a null terminating byte.

## Close

Sends all sessions in the set to the server.

### Visual Basic Syntax

Sub Close()

### C++ Syntax

HRESULT Close();

## GetLastError

Returns the error code, or 0 if there was no error.

### Visual Basic Syntax

Sub GetLastError() As Long

### C++ Syntax

HRESULT GetLastError([out] long);

### Return Value

Returns the error code.

## GetLastErrorObject

Returns a MTMeterError object that holds information about the last error. The MTMeterError object must be deleted after it is used.

### Visual Basic Syntax

Sub GetLastErrorObject() As MTMeterError

### C++ Syntax

HRESULT GetLastErrorObject([out] * MTMeterError);

### Return Value

MTMeterError object, containing details about the last error.

## ToXML

This method will convert the session set into its XML representation.

### Visual Basic Syntax

Function ToXML as String

### C++ Syntax

HRESULT ToXML([out, retval] BSTR * xml);

### Return Value

MSIX/XML representation of the session set

## FromXML

Converts a session into its XML representation.

### Visual Basic Syntax

Function FromXML (aXMLString) as String

### C++ Syntax

HRESULT FromXML([in]BSTR aXMLString);

# Property Detail

## SecurityContext

Sets and gets the security context for the caller or actor.

### Visual Basic Syntax

Property TransactionID As Variant

Property TransactionID (IMTSecurityContext As Variant)

### C++ Syntax

HRESULT SecurityContext([out, retval] IMTSecurityContext** pVal);

HRESULT SecurityContext([in] IMTSecurityContext* newVal);

## TransactionID

Gets/sets the distributed transaction ID that this set belongs to.

This is a read-write property.

### Visual Basic Syntax

Property TransactionID As Char

### C++ Syntax

HRESULT ID([in, out] const char * transactionID);

### Argument

transactionID

The ID of the transaction.

## SessionContext

Gets/sets the session context; used for Authentication and Authorization.

The SessionContext property holds the caller's serialized session context. If it is set, the other credential properties (SessionContextUserName, SessionContextUserNamespace, SessionContextPassword) are ignored.

If this property is not set, then all three credential properties have to be set.

This is a read-write property.

### Visual Basic Syntax

Property SessionContext (sessioncontext As Char)

### C++ Syntax

HRESULT ID([in, out] const char * sessioncontext);

### Argument

sessioncontext

The session context.

## SessionContextUserName

Gets/sets the username for the session; used for Authentication and Authorization.

This is a read-write property.

### Visual Basic Syntax

Property SessionContextUserName (username As Char)

### C++ Syntax

HRESULT ID([in, out] const char * username);

### Argument

username

The login name of the user for this session.

## SessionContextPassword

Gets/sets the password for the session; used for Authentication and Authorization..

This is a read-write property.

### Visual Basic Syntax

Property SessionContextPassword (password As Char)

### C++ Syntax

HRESULT ID([in, out] const char * password);

### Argument

password

The login password of the user for this session.

## SessionContextNamespace

Gets/sets the namespace for the session; used for Authentication and Authorization..

This is a read-write property.

### Visual Basic Syntax

Property SessionContextNamespace (mtnamespace As Char)

### C++ Syntax

HRESULT ID([in, out] const char * mtnamespace);

### Argument

mtnamespace

The namespace for the user for this session.