3.9.4.2.1 InitNew (Opnum 10)

The InitNew method is received by the server in an RPC_REQUEST packet. In response, the server MUST initialize an MSMQ transaction object to represent an existing underlying transaction object.

 HRESULT InitNew(
   [in] VARIANT varTransaction
 );

varTransaction: A pointer to a VARIANT that points to an existing underlying transaction object that is implementing the ITransaction interface. The VARIANT that is passed can be any one of the following types:

  • VT_UNKNOWN

  • VT_UNKNOWN | VT_BYREF

  • VT_DISPATCH

  • VT_DISPATCH | VT_BYREF

Return Values: The method MUST return S_OK (0x00000000) to indicate success or an implementation-specific error HRESULT on failure.

When the server processes this call, it MUST follow these guidelines:

  • If the Transaction instance variable is NOT NULL:

    • Return MQ_ERROR_TRANSACTION_USAGE (0xC00E0050), and take no further action.

  • Retrieve the transaction object, referred to as rTransObj, from the varTransaction VARIANT based on the type of the VARIANT as follows:

    • If varTransaction.vt is VT_UNKNOWN then set rTransObj to varTransaction.punkVal.

    • Else if varTransaction.vt is VT_UNKNOWN | VT_BYREF then set rTransObj to varTransaction.ppunkVal.

    • Else if varTransaction.vt is VT_DISPATCH then set rTransObj to varTransaction.pdispVal.

    • Else if varTransaction.vt is VT_ DISPATCH | VT_BYREF then set rTransObj to varTransaction.ppdispVal.

    • Otherwise return E_INVALIDARG (0x80070057).

  • Retrieve the transaction object that is implementing the ITransaction interface by calling IUnknown::QueryInterface (section 3.1) on rTransObj, passing the interface identifier of ITransaction.

  • Return E_INVALIDARG (0x80070057) if the varTransaction input parameter does not implement the ITransaction interface, and take no further action.

  • Set the Transaction instance variable to the value of the transaction object previously obtained.