/// <summary> /// Parse the GetProps request type response body. /// </summary> /// <param name="rawData">The raw data of response.</param> /// <returns>The GetProps request type response body.</returns> public static GetPropsResponseBody Parse(byte[] rawData) { GetPropsResponseBody responseBody = new GetPropsResponseBody(); int index = 0; responseBody.StatusCode = BitConverter.ToUInt32(rawData, index); index += sizeof(uint); responseBody.ErrorCode = BitConverter.ToUInt32(rawData, index); index += sizeof(uint); responseBody.CodePage = BitConverter.ToUInt32(rawData, index); index += sizeof(uint); responseBody.HasPropertyValues = BitConverter.ToBoolean(rawData, index); index += sizeof(bool); if (responseBody.HasPropertyValues) { responseBody.PropertyValues = AddressBookPropertyValueList.Parse(rawData, ref index); } else { responseBody.PropertyValues = null; } responseBody.AuxiliaryBufferSize = BitConverter.ToUInt32(rawData, index); index += 4; responseBody.AuxiliaryBuffer = new byte[responseBody.AuxiliaryBufferSize]; Array.Copy(rawData, index, responseBody.AuxiliaryBuffer, 0, responseBody.AuxiliaryBufferSize); return(responseBody); }
/// <summary> /// This method is used by the client to get specific properties on an object. /// </summary> /// <param name="getPropsRequestBody">The GetProps request type request body.</param> /// <param name="responseCodeHeader">The value of X-ResponseCode header</param> /// <returns>The response body of the GetProps request type.</returns> public GetPropsResponseBody GetProps(GetPropsRequestBody getPropsRequestBody, out uint responseCodeHeader) { byte[] rawBuffer; CommonResponse commonResponse = null; WebHeaderCollection webHeaderCollection = AdapterHelper.InitializeHTTPHeader(RequestType.GetProps, AdapterHelper.ClientInstance, AdapterHelper.Counter); // Send the Execute HTTP request and get the response. HttpWebResponse response = this.SendMAPIHttpRequest(this.userName, this.password, getPropsRequestBody, ServerEndpoint.AddressBookServerEndpoint, AdapterHelper.SessionContextCookies, webHeaderCollection, out rawBuffer); responseCodeHeader = AdapterHelper.GetFinalResponseCode(response.Headers["X-ResponseCode"]); // Read the HTTP response buffer and parse the response to correct format. commonResponse = CommonResponse.ParseCommonResponse(rawBuffer); response.GetResponseStream().Close(); AdapterHelper.SessionContextCookies = response.Cookies; GetPropsResponseBody getPropsResponseBody = new GetPropsResponseBody(); if (commonResponse.ResponseBodyRawData.Length > 0) { getPropsResponseBody = GetPropsResponseBody.Parse(commonResponse.ResponseBodyRawData); } return(getPropsResponseBody); }
/// <summary> /// Parse the GetProps request type response body. /// </summary> /// <param name="rawData">The raw data of response.</param> /// <returns>The GetProps request type response body.</returns> public static GetPropsResponseBody Parse(byte[] rawData) { GetPropsResponseBody responseBody = new GetPropsResponseBody(); int index = 0; responseBody.StatusCode = BitConverter.ToUInt32(rawData, index); index += sizeof(uint); responseBody.ErrorCode = BitConverter.ToUInt32(rawData, index); index += sizeof(uint); responseBody.CodePage = BitConverter.ToUInt32(rawData, index); index += sizeof(uint); responseBody.HasPropertyValues = BitConverter.ToBoolean(rawData, index); index += sizeof(bool); if (responseBody.HasPropertyValues) { responseBody.PropertyValues = AddressBookPropertyValueList.Parse(rawData, ref index); } else { responseBody.PropertyValues = null; } responseBody.AuxiliaryBufferSize = BitConverter.ToUInt32(rawData, index); index += 4; responseBody.AuxiliaryBuffer = new byte[responseBody.AuxiliaryBufferSize]; Array.Copy(rawData, index, responseBody.AuxiliaryBuffer, 0, responseBody.AuxiliaryBufferSize); return responseBody; }
/// <summary> /// This method is used by the client to get specific properties on an object. /// </summary> /// <param name="getPropsRequestBody">The GetProps request type request body.</param> /// <returns>The response body of the GetProps request type.</returns> public GetPropsResponseBody GetProps(GetPropsRequestBody getPropsRequestBody) { CommonResponse commonResponse = this.SendAddressBookRequest(getPropsRequestBody, RequestType.GetProps); GetPropsResponseBody getPropsResponseBody = GetPropsResponseBody.Parse(commonResponse.ResponseBodyRawData); this.VerifyGetPropsResponseBody(getPropsResponseBody); return(getPropsResponseBody); }
/// <summary> /// Verify the requirements related to GetProps request type response body. /// </summary> /// <param name="getPropsResponseBody">The response body of GetProps request type.</param> private void VerifyGetPropsResponseBody(GetPropsResponseBody getPropsResponseBody) { // Add the debug information this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCMAPIHTTP_R619"); // Verify MS-OXCMAPIHTTP requirement: MS-OXCMAPIHTTP_R619 this.Site.CaptureRequirementIfIsInstanceOfType( getPropsResponseBody.StatusCode, typeof(uint), 619, @"[In GetProps Request Type Success Response Body] StatusCode (4 bytes): An unsigned integer that specifies the status of the request."); // Add the debug information this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCMAPIHTTP_R620"); // Verify MS-OXCMAPIHTTP requirement: MS-OXCMAPIHTTP_R620 this.Site.CaptureRequirementIfAreEqual<uint>( 0, getPropsResponseBody.StatusCode, 620, @"[In GetProps Request Type Success Response Body] [StatusCode] This field MUST be set to 0x00000000."); // Add the debug information this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCMAPIHTTP_R621"); // Verify MS-OXCMAPIHTTP requirement: MS-OXCMAPIHTTP_R621 this.Site.CaptureRequirementIfIsInstanceOfType( getPropsResponseBody.ErrorCode, typeof(uint), 621, @"[In GetProps Request Type Success Response Body] ErrorCode (4 bytes): An unsigned integer that specifies the return status of the operation."); // Add the debug information this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCMAPIHTTP_R622"); // Verify MS-OXCMAPIHTTP requirement: MS-OXCMAPIHTTP_R622 this.Site.CaptureRequirementIfIsInstanceOfType( getPropsResponseBody.CodePage, typeof(uint), 622, @"[In GetProps Request Type Success Response Body] CodePage (4 bytes): An unsigned integer that specifies the code page that the server used to express string properties."); // Add the debug information this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCMAPIHTTP_R623"); // Verify MS-OXCMAPIHTTP requirement: MS-OXCMAPIHTTP_R623 this.Site.CaptureRequirementIfIsInstanceOfType( getPropsResponseBody.HasPropertyValues, typeof(bool), 623, @"[In GetProps Request Type Success Response Body] HasPropertyValues (1 byte): A Boolean value that specifies whether the PropertyValues field is present."); if (getPropsResponseBody.HasPropertyValues) { // Add the debug information this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCMAPIHTTP_R626"); // Verify MS-OXCMAPIHTTP requirement: MS-OXCMAPIHTTP_R626 // Because the HasPropertyValues field is true, so if the PropertyValues field has value, R626 will be verified. this.Site.CaptureRequirementIfIsNotNull( getPropsResponseBody.PropertyValues, 626, @"[In GetProps Request Type Success Response Body] [PropertyValues] This field is present when the value of the HasPropertyValues field is nonzero."); } else { // Add the debug information this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCMAPIHTTP_R627"); // Verify MS-OXCMAPIHTTP requirement: MS-OXCMAPIHTTP_R627 // Because the HasPropertyValues field is false, so if the PropertyValues field has not value, R627 will be verified. this.Site.CaptureRequirementIfIsNull( getPropsResponseBody.PropertyValues, 627, @"[In GetProps Request Type Success Response Body] [PropertyValues] This field is not present when the value of the HasPropertyValues field is zero."); } // Add the debug information this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCMAPIHTTP_R628"); // Verify MS-OXCMAPIHTTP requirement: MS-OXCMAPIHTTP_R628 this.Site.CaptureRequirementIfIsInstanceOfType( getPropsResponseBody.AuxiliaryBufferSize, typeof(uint), 628, @"[In GetProps Request Type Success Response Body] AuxiliaryBufferSize (4 bytes): An unsigned integer that specifies the size, in bytes, of the AuxiliaryBuffer field."); // Add the debug information this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCMAPIHTTP_R629"); // Verify MS-OXCMAPIHTTP requirement: MS-OXCMAPIHTTP_R629 this.Site.CaptureRequirementIfIsInstanceOfType( getPropsResponseBody.AuxiliaryBuffer, typeof(byte[]), 629, @"[In GetProps Request Type Success Response Body] AuxiliaryBuffer (variable): An array of bytes that constitute the auxiliary payload data returned from the server."); // Add the debug information this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCMAPIHTTP_R630"); // Verify MS-OXCMAPIHTTP requirement: MS-OXCMAPIHTTP_R630 this.Site.CaptureRequirementIfAreEqual<uint>( getPropsResponseBody.AuxiliaryBufferSize, (uint)getPropsResponseBody.AuxiliaryBuffer.Length, 630, @"[In GetProps Request Type Success Response Body] [AuxiliaryBuffer] The size of this field, in bytes, is specified by the AuxiliaryBufferSize field."); }
/// <summary> /// This method is used by the client to get specific properties on an object. /// </summary> /// <param name="getPropsRequestBody">The GetProps request type request body.</param> /// <param name="responseCodeHeader">The value of X-ResponseCode header</param> /// <returns>The response body of the GetProps request type.</returns> public GetPropsResponseBody GetProps(GetPropsRequestBody getPropsRequestBody,out uint responseCodeHeader) { byte[] rawBuffer; CommonResponse commonResponse = null; WebHeaderCollection webHeaderCollection = AdapterHelper.InitializeHTTPHeader(RequestType.GetProps, AdapterHelper.ClientInstance, AdapterHelper.Counter); // Send the Execute HTTP request and get the response. HttpWebResponse response = this.SendMAPIHttpRequest(this.userName, this.password, getPropsRequestBody, ServerEndpoint.AddressBookServerEndpoint, AdapterHelper.SessionContextCookies, webHeaderCollection, out rawBuffer); responseCodeHeader = AdapterHelper.GetFinalResponseCode(response.Headers["X-ResponseCode"]); // Read the HTTP response buffer and parse the response to correct format. commonResponse = CommonResponse.ParseCommonResponse(rawBuffer); response.GetResponseStream().Close(); AdapterHelper.SessionContextCookies = response.Cookies; GetPropsResponseBody getPropsResponseBody = new GetPropsResponseBody(); if (commonResponse.ResponseBodyRawData.Length > 0) { getPropsResponseBody= GetPropsResponseBody.Parse(commonResponse.ResponseBodyRawData); } return getPropsResponseBody; }