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

PING() public method

This method allows a client to determine whether a server's endpoint is reachable and operational.
public PING ( ServerEndpoint endpoint, List &metatags, WebHeaderCollection &headers ) : uint
endpoint ServerEndpoint The endpoint used by PING request.
metatags List The meta tags in the response body of the Ping request type.
headers System.Net.WebHeaderCollection The request and response header of the PING request type.
return uint
        public uint PING(ServerEndpoint endpoint, out List<string> metatags, out WebHeaderCollection headers)
        {
            metatags = null;
            byte[] rawBuffer;
            WebHeaderCollection webHeaderCollection = AdapterHelper.InitializeHTTPHeader(RequestType.PING, AdapterHelper.ClientInstance, AdapterHelper.Counter);

            // Send the PING HTTP request and get the response.
            HttpWebResponse response = this.SendMAPIHttpRequest(this.userName, this.password, null, endpoint, AdapterHelper.SessionContextCookies, webHeaderCollection, out rawBuffer);
            headers = response.Headers;

            // Read the HTTP response buffer and parse the response to correct format.
            uint responseCode = AdapterHelper.GetFinalResponseCode(response.Headers["X-ResponseCode"]);

            CommonResponse commonResponse = CommonResponse.ParseCommonResponse(rawBuffer);
            if (responseCode == 0)
            {
                // PING succeeded when the response code equals zero and PING request has no response body.
                metatags = commonResponse.MetaTags;
                this.VerifyHTTPS(response);
                this.VerifyAuthentication(response);
                this.VerifyAutoDiscover(response.StatusCode, endpoint);
                this.VerifyHTTPHeaders(response.Headers);
                this.VerifyAdditionalHeaders(commonResponse.AdditionalHeaders);
                this.VerifyPINGRequestType(commonResponse, endpoint, responseCode);
                this.VerifyResponseMetaTags(commonResponse.MetaTags);
            }

            this.VerifyContentTypeHeader(response.Headers);
            this.VerifyRespondingToAllRequestTypeRequests(response, commonResponse, responseCode);
            response.GetResponseStream().Close();
            return responseCode;
        }
        #endregion
MS_OXCMAPIHTTPAdapter