Microsoft.Protocols.TestSuites.MS_OXCMAPIHTTP.MS_OXCMAPIHTTPAdapter.Execute C# (CSharp) Method

Execute() public method

This method is used by the client to send remote operation requests to the server with specified cookies.
public Execute ( ExecuteRequestBody requestBody, CookieCollection cookies, WebHeaderCollection &httpHeaders, MailboxResponseBodyBase &responseBody, List &metatags ) : uint
requestBody Microsoft.Protocols.TestSuites.Common.ExecuteRequestBody The request body of the Execute request type.
cookies System.Net.CookieCollection Cookies used to identify the Session Context.
httpHeaders System.Net.WebHeaderCollection The request and response header of the Execute request type.
responseBody Microsoft.Protocols.TestSuites.Common.MailboxResponseBodyBase The response body of the Execute request type.
metatags List The meta tags in the response body buffer.
return uint
        public uint Execute(ExecuteRequestBody requestBody, CookieCollection cookies, ref WebHeaderCollection httpHeaders, out MailboxResponseBodyBase responseBody, out List<string> metatags)
        {
            responseBody = null;
            metatags = null;
            byte[] rawBuffer;

            // Send the execute HTTP request and get the response.
            HttpWebResponse response = this.SendMAPIHttpRequest(this.userName, this.password, requestBody, ServerEndpoint.MailboxServerEndpoint, cookies, httpHeaders, out rawBuffer);
            httpHeaders = response.Headers;
            uint responseCode = AdapterHelper.GetFinalResponseCode(response.Headers["X-ResponseCode"]);
             
            // Read the HTTP response buffer and parse the response to correct format.
            CommonResponse commonResponse = CommonResponse.ParseCommonResponse(rawBuffer);
            metatags = commonResponse.MetaTags;
            if (responseCode == 0)
            {
                Site.Assert.IsNotNull(commonResponse.ResponseBodyRawData, "The response body should contains data.");
                uint statusCode = BitConverter.ToUInt32(commonResponse.ResponseBodyRawData, 0);
                if (statusCode == 0)
                {
                    // Execute request type executed successfully when the StatusCode field equals zero.
                    ExecuteSuccessResponseBody responseSuccess = ExecuteSuccessResponseBody.Parse(commonResponse.ResponseBodyRawData);
                    responseBody = responseSuccess;

                    this.VerifyHTTPS(response);
                    this.VerifyExecuteSuccessResponseBody(responseSuccess);
                }

                this.VerifyHTTPHeaders(response.Headers);
                this.VerifyAuthentication(response);
                this.VerifyAutoDiscover(response.StatusCode, ServerEndpoint.MailboxServerEndpoint);
                this.VerifyAdditionalHeaders(commonResponse.AdditionalHeaders);
                this.VerifyRequestTypesForMailboxServerEndpoint(response.Headers, commonResponse);
                this.VerifyResponseMetaTags(commonResponse.MetaTags);
            }

            this.VerifyContentTypeHeader(response.Headers);
            this.VerifyRespondingToAllRequestTypeRequests(response, commonResponse, responseCode);
            response.GetResponseStream().Close();
            AdapterHelper.SessionContextCookies = response.Cookies;
            return responseCode;
        }
MS_OXCMAPIHTTPAdapter