/// <summary>
        /// Creates an item or file attachment on an item.
        /// </summary>
        /// <param name="parentItemId">Identifies the parent item in the server store that contains the attachment.</param>
        /// <param name="attachmentsType">Attachment type.</param>
        /// <returns>A response message for "CreateAttachment" operation.</returns>
        protected CreateAttachmentResponseType CallCreateAttachmentOperation(string parentItemId, params AttachmentTypeValue[] attachmentsType)
        {
            // Configure attachments.
            int attachmentCount = attachmentsType.Length;
            this.Attachments = new AttachmentType[attachmentCount];
            for (int attachmentIndex = 0; attachmentIndex < attachmentCount; attachmentIndex++)
            {
                AttachmentType attachment = null;

                if (attachmentsType[attachmentIndex] == AttachmentTypeValue.FileAttachment)
                {
                    FileAttachmentType fileAttachment = new FileAttachmentType()
                    {
                        ContentLocation = @"http://www.contoso.com/xyz.abc",
                        Name = "attach.jpg",

                        // Ensure content id is unique.
                        ContentId = Guid.NewGuid().ToString(),
                        ContentType = "image/jpeg",
                        Content = Convert.FromBase64String("/9j/4AAQSkZJRgABAQEAYABgAAD/7AARRHVja3kAAQAEAAAARgAA/9sAQwACAQECAQECAgICAgICAgMFAwMDAwMGBAQDBQcGBwcHBgcHCAkLCQgICggHBwoNCgoLDAwMDAcJDg8NDA4LDAwM/9sAQwECAgIDAwMGAwMGDAgHCAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwM/8AAEQgADAAUAwEiAAIRAQMRAf/EAB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+v/EAB8BAAMBAQEBAQEBAQEAAAAAAAABAgMEBQYHCAkKC//EALURAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYSQVEHYXETIjKBCBRCkaGxwQkjM1LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm5+jp6vLz9PX29/j5+v/aAAwDAQACEQMRAD8A5j9hnXPH/gy003RdI+KejWVjciO7muPF86y2GiWFu3nahceUJUyEtfOcKroplMZeSJAxH1j+2p8f9L8TfBTw1qvwo8YSSWGr6FB4p1bStWsLi01TVPDl4ZLe21CwkeOJ9yXf2cSQlCfKukdjDvhM34beLf2n/G3wz+B2g+ItA1qbS9Y0bxBm1uIlDFA9vPG6kNkFWQlSp4welZfxG/4K1fHj9ozQj4T8V+N73U9J1u7e7uxLmWU+YYWaGJ5Cxt7fzLeF/s8Hlxbox8mABXNQjVjQnQlVk+zurrRbWSXnbbuedTyvD0ISoQvZ333WnyPqLxp8PG8feIrjU5dG8O60ZWMYuDeW1tjyyUKeWzALtZWGFG3Oe+aK/OP4ja3c+CfiZ4m07TJTbWdvq90iIQJSAsrKMs+WJwo6miuFZRbT2svvX+QoZTQirXf4f5H/2Q==")
                    };

                    attachment = fileAttachment;
                }
                else if (attachmentsType[attachmentIndex] == AttachmentTypeValue.ReferenceAttachment)
                {
                    ReferenceAttachmentType referenceAttachment = new ReferenceAttachmentType()
                    {
                        AttachLongPathName = @"http://www.contoso.com/xyz.abc",
                        ProviderType = "abc",
                        ProviderEndpointUrl = @"http://www.contoso.com",
                        AttachmentPreviewUrl = @"http://www.contoso.com/Preview.abc",
                        AttachmentThumbnailUrl = @"http://www.contoso.com/Thumbnail.abc",
                        ContentLocation = @"http://www.contoso.com/xyz.abc",
                        Name = "RefAttachment",
                        ContentId = Guid.NewGuid().ToString(),
                        ContentType = "image/jpeg",
                    };

                    attachment = referenceAttachment;
                }
                else 
                {
                    ItemAttachmentType itemAttachment = new ItemAttachmentType()
                    {
                        ContentLocation = @"http://www.contoso.com/xyz.abc",
                        Name = "ItemName",

                        // Ensure content id is unique.
                        ContentId = Guid.NewGuid().ToString(),
                        ContentType = "image/jpeg",
                    };

                    switch (attachmentsType[attachmentIndex])
                    {
                        case AttachmentTypeValue.ItemAttachment:
                            itemAttachment.Item = new ItemType();
                            break;

                        case AttachmentTypeValue.MessageAttachment:
                            itemAttachment.Item = new MessageType() 
                            {
                                Body = new BodyType() 
                                {
                                    BodyType1 = BodyTypeType.HTML,
                                    Value = "<html><body><b>Bold</b><script>alert('Alert!');</script></body></html>"
                                },
                            };
                            break;

                        case AttachmentTypeValue.CalendarAttachment:
                            itemAttachment.Item = new CalendarItemType()
                            {
                                StartSpecified = true,
                                EndSpecified = true
                            };
                            break;

                        case AttachmentTypeValue.ContactAttachment:
                            itemAttachment.Item = new ContactItemType();
                            break;

                        case AttachmentTypeValue.PostAttachment:
                            itemAttachment.Item = new PostItemType();
                            break;

                        case AttachmentTypeValue.TaskAttachment:
                            itemAttachment.Item = new TaskType();
                            break;

                        case AttachmentTypeValue.MeetingMessageAttachemnt:
                            itemAttachment.Item = new MeetingMessageType();
                            break;

                        case AttachmentTypeValue.MeetingRequestAttachment:
                            itemAttachment.Item = new MeetingRequestMessageType();
                            break;

                        case AttachmentTypeValue.MeetingResponseAttachment:
                            itemAttachment.Item = new MeetingResponseMessageType();
                            break;

                        case AttachmentTypeValue.MeetingCancellationAttachment:
                            itemAttachment.Item = new MeetingCancellationMessageType();
                            break;
                        
                        case AttachmentTypeValue.PersonAttachment:
                            itemAttachment.Item = new AbchPersonItemType()
                            {
                                AntiLinkInfo = "",
                                PersonId = Guid.NewGuid().ToString(),
                                ContactHandles = new AbchPersonContactHandle[] { 
                                    new AbchPersonContactHandle(),
                                },
                                ContactCategories = new string[] { 
                                    "test category"
                                },
                            };
                            break;
                    }

                    attachment = itemAttachment;
                }

                this.Attachments[attachmentIndex] = attachment;
            }

            CreateAttachmentType createAttachmentRequest = new CreateAttachmentType()
            {
                ParentItemId = new ItemIdType()
                {
                    Id = parentItemId
                },
                Attachments = this.Attachments
            };

            return this.ATTAdapter.CreateAttachment(createAttachmentRequest);
        }
        /// <summary>
        /// Verify the ReferenceAttachmentType related requirements.
        /// </summary>
        private void verifyReferenceAttachmentType(bool isSchemaValidated,ReferenceAttachmentType referenceAttachment)
        {
            if (referenceAttachment != null)
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSATT_R38001");

                // Verify MS-OXWSATT requirement: MS-OXWSATT_R38001
                this.Site.CaptureRequirementIfIsTrue(
                    isSchemaValidated,
                    38001,
                    @"[In t:ArrayOfAttachmentsType Complex Type][The type of element ReferenceAttachment is] t:ReferenceAttachmentType (section 2.2.4.8).");


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

                // Verify MS-OXWSATT requirement: MS-OXWSATT_R441
                this.Site.CaptureRequirementIfIsTrue(
                    isSchemaValidated,
                    104003,
                    @"[t:ReferenceAttachmentType Complex Type] [The ReferenceAttachmentType Complex Type is defined as follow:]
<xs:complexType name=""ReferenceAttachmentType"">
   <xs:complexContent>
     <xs:extension base=""t:AttachmentType"">
       <xs:sequence>
         <xs:element name=""AttachLongPathName"" type=""xs:string"" minOccurs=""0"" maxOccurs=""1""/>
         <xs:element name=""ProviderType"" type=""xs:string"" minOccurs=""0"" maxOccurs=""1""/>
      <xs:element name=""ProviderEndpointUrl"" type=""xs:string"" minOccurs=""0"" maxOccurs=""1""/>
      <xs:element name=""AttachmentThumbnailUrl"" type=""xs:string"" minOccurs=""0"" maxOccurs=""1""/>
      <xs:element name=""AttachmentPreviewUrl"" type=""xs:string"" minOccurs=""0"" maxOccurs=""1""/>
      <xs:element name=""PermissionType"" type=""xs:int"" minOccurs=""0"" maxOccurs=""1""/>
      <xs:element name=""AttachmentIsFolder"" type=""xs:boolean"" minOccurs=""0"" maxOccurs=""1""/>
       </xs:sequence>
     </xs:extension>
   </xs:complexContent>
 </xs:complexType>");

                if (!string.IsNullOrEmpty(referenceAttachment.AttachLongPathName))
                {
                    // Add the debug information
                    Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSATT_R104005");

                    // Verify MS-OXWSATT requirement: MS-OXWSATT_R104005
                    this.Site.CaptureRequirementIfIsTrue(
                        isSchemaValidated,
                        104005,
                        @"[t:ReferenceAttachmentType Complex Type] [The type of AttachLongPathName element is] xs:string([XMLSCHEMA2])");
                }

                if (!string.IsNullOrEmpty(referenceAttachment.ProviderType))
                {
                    // Add the debug information
                    Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSATT_R104007");

                    // Verify MS-OXWSATT requirement: MS-OXWSATT_R104007
                    this.Site.CaptureRequirementIfIsTrue(
                        isSchemaValidated,
                        104007,
                        @"[t:ReferenceAttachmentType Complex Type] [The type of ProviderType element is] xs:string.");
                }

                if (!string.IsNullOrEmpty(referenceAttachment.ProviderEndpointUrl))
                {
                    // Add the debug information
                    Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSATT_R104009");

                    // Verify MS-OXWSATT requirement: MS-OXWSATT_R104009
                    this.Site.CaptureRequirementIfIsTrue(
                        isSchemaValidated,
                        104009,
                        @"[t:ReferenceAttachmentType Complex Type] [The type of ProviderEndpointUrl element is] xs:string.");
                }

                if (!string.IsNullOrEmpty(referenceAttachment.AttachmentThumbnailUrl))
                {
                    // Add the debug information
                    Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSATT_R104011");

                    // Verify MS-OXWSATT requirement: MS-OXWSATT_R104011
                    this.Site.CaptureRequirementIfIsTrue(
                        isSchemaValidated,
                        104011,
                        @"[t:ReferenceAttachmentType Complex Type] [The type of AttachmentThumbnailUrl element is] xs:string.");
                }

                if (!string.IsNullOrEmpty(referenceAttachment.AttachmentPreviewUrl))
                {
                    // Add the debug information
                    Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSATT_R104013");

                    // Verify MS-OXWSATT requirement: MS-OXWSATT_R104013
                    this.Site.CaptureRequirementIfIsTrue(
                        isSchemaValidated,
                        104013,
                        @"[t:ReferenceAttachmentType Complex Type] [The type of AttachmentPreviewUrl element is] xs:string.");
                }

                if (referenceAttachment.PermissionTypeSpecified == true)
                {
                    // Add the debug information
                    Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSATT_R104015");

                    // Verify MS-OXWSATT requirement: MS-OXWSATT_R104015
                    this.Site.CaptureRequirementIfIsTrue(
                        isSchemaValidated,
                        104015,
                        @"[t:ReferenceAttachmentType Complex Type] [The type of PermissionType element is] xs:int([XMLSCHEMA2] ).");
                }

                if (referenceAttachment.AttachmentIsFolderSpecified == true)
                {
                    // Add the debug information
                    Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSATT_R104017");

                    // Verify MS-OXWSATT requirement: MS-OXWSATT_R104017
                    this.Site.CaptureRequirementIfIsTrue(
                        isSchemaValidated,
                        104017,
                        @"[t:ReferenceAttachmentType Complex Type] [The type of AttachmentIsFolder element is] xs:Boolean([XMLSCHEMA2] )");
                }
            }
        }