/// <summary> /// Creates an item or file attachment on an item in the server store. /// </summary> /// <param name="createAttachmentRequest">A CreateAttachmentType complex type specifies a request message to attach an item or file to a specified item in the server database. </param> /// <returns>A CreateAttachmentResponseType complex type specifies the response message that is returned by the CreateAttachment operation. </returns> public CreateAttachmentResponseType CreateAttachment(CreateAttachmentType createAttachmentRequest) { CreateAttachmentResponseType createAttachmentResponse = this.exchangeServiceBinding.CreateAttachment(createAttachmentRequest); Site.Assert.IsNotNull(createAttachmentResponse, "If the operation is successful, the response should not be null."); this.VerifySoapVersion(); this.VerifyTransportType(); this.VerifyServerVersionInfo(this.exchangeServiceBinding.IsSchemaValidated); if (createAttachmentResponse.ResponseMessages.Items[0].ResponseClass == ResponseClassType.Success) { this.VerifyCreateAttachmentResponse(createAttachmentResponse, this.exchangeServiceBinding.IsSchemaValidated); } return(createAttachmentResponse); }
/// <summary> /// Verify the CreateAttachment operation response. /// </summary> /// <param name="createAttachmentResponse">A CreateAttachmentResponseType instance.</param> private void VerifyCreateAttachmentSuccessfulResponse(CreateAttachmentResponseType createAttachmentResponse) { foreach (AttachmentInfoResponseMessageType createAttachmentInfoResponse in createAttachmentResponse.ResponseMessages.Items) { // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSATT_R144"); // Verify MS-OXWSATT requirement: MS-OXWSATT_R144 Site.CaptureRequirementIfAreEqual<ResponseClassType>( ResponseClassType.Success, createAttachmentInfoResponse.ResponseClass, 144, @"[In CreateAttachment Operation] If the request is successful, the CreateAttachment operation returns a CreateAttachmentResponse element with the ResponseClass attribute of the CreateAttachmentResponseMessage element set to ""Success"". "); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSATT_R145"); // Verify MS-OXWSATT requirement: MS-OXWSATT_R145 Site.CaptureRequirementIfAreEqual<ResponseCodeType>( ResponseCodeType.NoError, createAttachmentInfoResponse.ResponseCode, 145, @"[In CreateAttachment Operation][A successful CreateAttachment operation request returns a CreateAttachmentResponse element] The ResponseCode element of the CreateAttachmentResponse element is set to ""NoError""."); } }
/// <summary> /// The capture code for requirements of CreateAttachment operation. /// </summary> /// <param name="createAttachmentResponse">CreateAttachmentResponseType createAttachmentResponse</param> /// <param name="isSchemaValidated">Indicate whether the schema is verified</param> private void VerifyCreateAttachmentResponse(CreateAttachmentResponseType createAttachmentResponse, bool isSchemaValidated) { // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSATT_R372"); // Verify MS-OXWSATT requirement: MS-OXWSATT_R372 Site.CaptureRequirementIfIsTrue( isSchemaValidated, 372, @"[In tns:CreateAttachmentSoapOut Message][The element of CreateAttachmentResult part is] tns:CreateAttachmentResponse (section 3.1.4.1.2.2)."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSATT_R553"); // Verify MS-OXWSATT requirement: MS-OXWSATT_R553 Site.CaptureRequirementIfIsTrue( isSchemaValidated, 553, @"[In tns:CreateAttachmentSoapOut Message][The element of ServerVersion part is] t:ServerVersionInfo ([MS-OXWSCDATA] section 2.2.3.12)."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSATT_R542"); // Verify MS-OXWSATT requirement: MS-OXWSATT_R542 Site.CaptureRequirementIfIsTrue( isSchemaValidated, 542, @"[In tns:CreateAttachmentSoapOut Message][The ServerVersion part] Specifies a SOAP header that identifies the server version for the response."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSATT_R543"); // Verify MS-OXWSATT requirement: MS-OXWSATT_R543 Site.CaptureRequirementIfIsTrue( isSchemaValidated, 543, @"[In Elements] [Element name] CreateAttachmentResponse Specifies the response body content from a request to create an attachment."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSATT_R545"); // Verify MS-OXWSATT requirement: MS-OXWSATT_R545 Site.CaptureRequirementIfIsTrue( isSchemaValidated, 545, @"[In Complex Types] [Complex type name] CreateAttachmentResponseType [Description] Specifies a response message for the CreateAttachment operation."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSATT_R535"); // Verify MS-OXWSATT requirement: MS-OXWSATT_R535 Site.CaptureRequirementIfIsTrue( isSchemaValidated, 535, @"[In CreateAttachment Operation] The following is the WSDL port type specification of the CreateAttachment operation. <wsdl:operation name=""CreateAttachment""> <wsdl:input message=""tns:CreateAttachmentSoapIn"" /> <wsdl:output message=""tns:CreateAttachmentSoapOut"" /> </wsdl:operation>"); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSATT_R320"); // Verify MS-OXWSATT requirement: MS-OXWSATT_R320 Site.CaptureRequirementIfIsTrue( isSchemaValidated, 320, @"[In CreateAttachment Operation] The following is the WSDL binding specification of the CreateAttachment operation. <wsdl:operation name=""CreateAttachment""> <soap:operation soapAction=""http://schemas.microsoft.com/exchange/services/2006/messages/CreateAttachment"" /> <wsdl:input> <soap:header message=""tns:CreateAttachmentSoapIn"" part=""Impersonation"" use=""literal""/> <soap:header message=""tns:CreateAttachmentSoapIn"" part=""MailboxCulture"" use=""literal""/> <soap:header message=""tns:CreateAttachmentSoapIn"" part=""RequestVersion"" use=""literal""/> <soap:header message=""tns:CreateAttachmentSoapIn"" part=""TimeZoneContext"" use=""literal""/> <soap:body parts=""request"" use=""literal"" /> </wsdl:input> <wsdl:output> <soap:body parts=""CreateAttachmentResult"" use=""literal"" /> <soap:header message=""tns:CreateAttachmentSoapOut"" part=""ServerVersion"" use=""literal""/> </wsdl:output> </wsdl:operation>"); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSATT_R539"); // Verify MS-OXWSATT requirement: MS-OXWSATT_R539 Site.CaptureRequirementIfIsTrue( isSchemaValidated, 539, @"[In tns:CreateAttachmentSoapIn Message][The RequestVersion part] Specifies a SOAP header that identifies the schema version for the CreateAttachment operation request."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSATT_R537"); // Verify MS-OXWSATT requirement: MS-OXWSATT_R537 Site.CaptureRequirementIfIsTrue( isSchemaValidated, 537, @"[In Messages][The CreateAttachmentSoapOut message] Specifies the SOAP message that is returned by the server in response."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSATT_R165"); // Verify MS-OXWSATT requirement: MS-OXWSATT_R165 Site.CaptureRequirementIfIsTrue( isSchemaValidated, 165, @"[In tns:CreateAttachmentSoapOut Message] The CreateAttachmentSoapOut WSDL message specifies the server response to the CreateAttachment operation request to create an attachment. <wsdl:message name=""CreateAttachmentSoapOut""> <wsdl:part name=""CreateAttachmentResult"" element=""tns:CreateAttachmentResponse"" /> <wsdl:part name=""ServerVersion"" element=""t:ServerVersionInfo""/> </wsdl:message>"); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSATT_R182"); // Verify MS-OXWSATT requirement: MS-OXWSATT_R182 Site.CaptureRequirementIfIsTrue( isSchemaValidated, 182, @"[In m:CreateAttachmentResponseType Complex Type][The CreateAttachmentResponseType is defined as follow:] <xs:complexType name=""CreateAttachmentResponseType""> <xs:complexContent> <xs:extension base=""m:BaseResponseMessageType"" /> </xs:complexContent> </xs:complexType>"); AttachmentIdType attachmentId = (createAttachmentResponse.ResponseMessages.Items[0] as AttachmentInfoResponseMessageType).Attachments[0].AttachmentId; // AttachmentIdType is optional in AttachmentType if (attachmentId != null) { // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSATT_R333"); // Verify MS-OXWSATT requirement: MS-OXWSATT_R333 Site.CaptureRequirementIfIsTrue( isSchemaValidated, 333, @"[In t:AttachmentIdType Complex Type][The type of RootItemId attribute is] xs:string ([XMLSCHEMA2])."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSATT_R439"); // Verify MS-OXWSATT requirement: MS-OXWSATT_R439 // Validate the length of RootItemId is no more than 512 bytes after base64 decoding. Site.Log.Add(LogEntryKind.Debug, "Length of root item id is:{0}", attachmentId.RootItemId.Length); bool isVerifyR439 = attachmentId.RootItemId.Length <= 512; Site.CaptureRequirementIfIsTrue( isVerifyR439, 439, @"[In t:AttachmentIdType Complex Type][In RootItemId] The length of RootItemId attribute is no more than 512 bytes after base64 decoding."); if (attachmentId.RootItemChangeKey != null) { // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSATT_R334"); // Verify MS-OXWSATT requirement: MS-OXWSATT_R334 Site.CaptureRequirementIfIsTrue( isSchemaValidated, 334, @"[In t:AttachmentIdType Complex Type][The type of RootItemChangeKey attribute is] xs:string."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSATT_R440"); // Verify MS-OXWSATT requirement: MS-OXWSATT_R440 // Validate the length of RootItemChangeKey is no more than 512 bytes after base64 decoding. Site.Log.Add(LogEntryKind.Debug, "Length of root item change key is:{0}", attachmentId.RootItemChangeKey.Length); bool isVerifyR440 = attachmentId.RootItemChangeKey.Length <= 512; Site.CaptureRequirementIfIsTrue( isVerifyR440, 440, @"[In t:AttachmentIdType Complex Type][In RootItemChangeKey] The length of RootItemChangeKey attribute is no more than 512 bytes after base64 decoding."); } } }