Inheritance: System.Web.Services.Protocols.SoapHeader
        /// <summary>
        /// Configure the SOAP header before calling operations.
        /// </summary>
        protected void ConfigureSOAPHeader()
        {
            // Set the value of MailboxCulture.
            MailboxCultureType mailboxCulture = new MailboxCultureType();
            string culture = Common.GetConfigurationPropertyValue("MailboxCulture", this.Site);
            mailboxCulture.Value = culture;

            // Set the value of ExchangeImpersonation.
            ExchangeImpersonationType impersonation = new ExchangeImpersonationType();
            impersonation.ConnectingSID = new ConnectingSIDType();
            PrimarySmtpAddressType address = new PrimarySmtpAddressType();
            address.Value = Common.GetConfigurationPropertyValue("User1Name", this.Site) + "@" + Common.GetConfigurationPropertyValue("Domain", this.Site);
            impersonation.ConnectingSID.Item = address;

            // Set time zone value.
            TimeZoneDefinitionType timezoneDefin = new TimeZoneDefinitionType();
            timezoneDefin.Id = "Eastern Standard Time";
            TimeZoneContextType timezoneContext = new TimeZoneContextType();
            timezoneContext.TimeZoneDefinition = timezoneDefin;

            Dictionary<string, object> headerValues = new Dictionary<string, object>();
            headerValues.Add("MailboxCulture", mailboxCulture);
            headerValues.Add("ExchangeImpersonation", impersonation);
            headerValues.Add("TimeZoneContext", timezoneContext);
            this.FOLDAdapter.ConfigureSOAPHeader(headerValues);
        }
        public void MSOXWSCORE_S04_TC20_VerifyOperationsWithSOAPHeaderSuccessful()
        {
            #region Step 1: Create one item with recipient.
            // Clear the soap header.
            this.ClearSoapHeaders();

            // Configure the SOAP headers for CreateItem and UpdateItem operations.
            Dictionary<string, object> headerValues = new Dictionary<string, object>();
            headerValues = this.ConfigureSOAPHeader();

            // Configure the TimeZoneContext SOAP Header.
            TimeZoneContextType timeZoneContext = new TimeZoneContextType();
            timeZoneContext.TimeZoneDefinition = new TimeZoneDefinitionType();
            timeZoneContext.TimeZoneDefinition.Id = TestSuiteHelper.TimeZoneID;

            headerValues.Add("TimeZoneContext", timeZoneContext);
            this.COREAdapter.ConfigureSOAPHeader(headerValues);

            // Call the CreateItem operation and save the item to Drafts folder.
            MessageType[] items = new MessageType[] { this.CreateItemWithOneRecipient() };

            CreateItemResponseType createItemResponse = this.CallCreateItemOperation(DistinguishedFolderIdNameType.drafts, items);

            // Check the operation response.
            Common.CheckOperationSuccess(createItemResponse, 1, this.Site);

            MessageType[] createdItems = Common.GetItemsFromInfoResponse<MessageType>(createItemResponse);

            // One created items should be returned.
            Site.Assert.AreEqual<int>(
                    1,
                    createdItems.GetLength(0),
                    "One created item should be returned! Expected Item Count: {0}, Actual Item Count: {1}",
                    1,
                    createdItems.GetLength(0));
            #endregion

            #region Step 2: Update the item which is created in Step 1.
            ItemChangeType[] itemChanges = new ItemChangeType[]
            {
                TestSuiteHelper.CreateItemChangeItem(createdItems[0], 1)
            };

            // Clear ExistItemIds list for MoveItem.
            this.InitializeCollection();

            // Call UpdateItem operation to update the subject of the created item, by using the ItemId in CreateItem response.
            UpdateItemResponseType updateItemResponse = this.CallUpdateItemOperation(
                DistinguishedFolderIdNameType.drafts,
                true,
                itemChanges);

            // Check the operation response.
            Common.CheckOperationSuccess(updateItemResponse, 1, this.Site);

            // Clear the soap header.
            this.ClearSoapHeaders();
            #endregion

            #region Step 3: Move the item updated in Step 2 from Drafts folder to Inbox folder.
            // Configure the SOAP headers for MoveItem and MarkAllItemsAsRead operations.
            headerValues.Remove("TimeZoneContext");
            this.COREAdapter.ConfigureSOAPHeader(headerValues);

            // Call the MoveItem operation, by using the ItemId in UpdateItem response.
            ItemIdType[] draftsItem = new ItemIdType[this.ExistItemIds.Count];
            this.ExistItemIds.CopyTo(draftsItem, 0);
            this.InitializeCollection();
            MoveItemResponseType moveItemResponse = this.CallMoveItemOperation(DistinguishedFolderIdNameType.inbox, draftsItem);

            // Check the operation response.
            Common.CheckOperationSuccess(moveItemResponse, 1, this.Site);
            #endregion

            #region Step 4: Mark all items in Inbox folder as read.
            // Exchange 2007 and Exchange 2010 do not support the MarkAllItemsAsRead operation.
            if (Common.IsRequirementEnabled(1290, this.Site))
            {
                // Configure Inbox folder as the target folder.
                BaseFolderIdType[] folderIds = new BaseFolderIdType[1];
                DistinguishedFolderIdType distinguishedFolder = new DistinguishedFolderIdType();
                distinguishedFolder.Id = DistinguishedFolderIdNameType.inbox;
                folderIds[0] = distinguishedFolder;

                // Mark all items in Inbox folder as unread, and suppress the receive receipts.
                MarkAllItemsAsReadResponseType markAllItemsAsReadResponse = this.CallMarkAllItemsAsReadOperation(true, true, folderIds);

                // Check the operation response.
                Common.CheckOperationSuccess(markAllItemsAsReadResponse, 1, this.Site);

                // Add the debug information
                this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCORE_R1290");

                // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R1290
                // The MarkAllItemsAsRead operation was executed successfully, so this requirement can be captured.
                this.Site.CaptureRequirementIfIsTrue(
                    this.IsSchemaValidated,
                    1290,
                    @"[In Appendix C: Product Behavior] Implementation does support the MarkAllItemsAsRead operation which marks all items in a folder as read. (Exchange 2013  and above follow this behavior.)");
            }

            // Clear the soap header.
            this.ClearSoapHeaders();
            #endregion

            #region Step 5: Get the item in Inbox folder.
            // Configure the SOAP headers for GetItem.
            headerValues.Add("TimeZoneContext", timeZoneContext);
            this.COREAdapter.ConfigureSOAPHeader(headerValues);

            // Call the GetItem operation, by using the ItemId in MoveItem response.
            ItemIdType[] itemArray = new ItemIdType[this.ExistItemIds.Count];
            this.ExistItemIds.CopyTo(itemArray, 0);
            GetItemResponseType getItemResponse = this.CallGetItemOperation(itemArray);

            // Check the operation response.
            Common.CheckOperationSuccess(getItemResponse, 1, this.Site);

            // Clear the soap header.
            this.ClearSoapHeaders();
            #endregion

            #region Step 6: Copy the message type item from Inbox folder to Drafts folder.
            // Configure the SOAP headers for CopyItem, SendItem and DeleteItem.
            headerValues.Remove("TimeZoneContext");
            this.COREAdapter.ConfigureSOAPHeader(headerValues);

            // Save the ID of the item in Inbox folder and call the CopyItem operation.
            itemArray = new ItemIdType[this.ExistItemIds.Count];
            this.ExistItemIds.CopyTo(itemArray, 0);
            CopyItemResponseType copyItemResponse = this.CallCopyItemOperation(DistinguishedFolderIdNameType.drafts, itemArray);

            // Check the operation response.
            Common.CheckOperationSuccess(copyItemResponse, 1, this.Site);

            ItemIdType[] copiedItemIds = Common.GetItemIdsFromInfoResponse(copyItemResponse);

            // One copied item should be returned.
            Site.Assert.AreEqual<int>(
                    1,
                    copiedItemIds.GetLength(0),
                    "One copied item should be returned! Expected Item Count: {0}, Actual Item Count: {1}",
                    1,
                    copiedItemIds.GetLength(0));
            #endregion

            #region Step 7: Send the item in Drafts folder.
            // Call SendItem to send the copied item in Drafts folder, by using copiedItemIds in CopyItem response.
            SendItemResponseType sendResponse = this.CallSendItemOperation(
                copiedItemIds,
                DistinguishedFolderIdNameType.sentitems,
                false);

            // Check the operation response.
            Common.CheckOperationSuccess(sendResponse, 1, this.Site);

            // Remove the sent itemId from ExistItemIds list, since the item has been sent out and no copy remains.
            this.ExistItemIds.Remove(copiedItemIds[0] as ItemIdType);
            #endregion

            #region Step 8: Delete the item in Inbox folder and clean all items sent out.
            // Delete the item in Inbox folder and clear the ExistItemIds list.
            DeleteItemResponseType deleteItemResponse = this.CallDeleteItemOperation();

            // Check the operation response.
            Common.CheckOperationSuccess(deleteItemResponse, 1, this.Site);

            this.InitializeCollection();

            // Clear the soap header.
            this.ClearSoapHeaders();

            // Clean the items sent out.
            this.CleanItemsSentOut(new string[] { items[0].Subject });
            #endregion
        }