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

Bind() public method

This method is used by the client to establish a Session Context with the Address Book Server.
public Bind ( BindRequestBody bindRequestBody, int &responseCode ) : BindResponseBody
bindRequestBody BindRequestBody The bind request type request body.
responseCode int The value of X-ResponseCode header of the bind response.
return BindResponseBody
        public BindResponseBody Bind(BindRequestBody bindRequestBody, out int responseCode)
        {
            byte[] rawBuffer = null;
            CommonResponse commonResponse = null;
            BindResponseBody bindResponseBody = null;
            AdapterHelper.Counter = 1;
            AdapterHelper.ClientInstance = Guid.NewGuid().ToString();
            WebHeaderCollection webHeaderCollection = AdapterHelper.InitializeHTTPHeader(RequestType.Bind, AdapterHelper.ClientInstance, AdapterHelper.Counter);

            // Send the Execute HTTP request and get the response.
            HttpWebResponse response = this.SendMAPIHttpRequest(this.userName, this.password, bindRequestBody, ServerEndpoint.AddressBookServerEndpoint, AdapterHelper.SessionContextCookies, webHeaderCollection, out rawBuffer);
            responseCode = (int)AdapterHelper.GetFinalResponseCode(response.Headers["X-ResponseCode"]);
          
            // Read the HTTP response buffer and parse the response to correct format.
            if (responseCode == 0)
            {
                commonResponse = CommonResponse.ParseCommonResponse(rawBuffer);
                Site.Assert.IsNotNull(commonResponse.ResponseBodyRawData, "The response body should contains data.");
                bindResponseBody = BindResponseBody.Parse(commonResponse.ResponseBodyRawData);
                this.VerifyBindResponseBody(bindResponseBody);
                this.VerifyAutoDiscover(response.StatusCode, ServerEndpoint.AddressBookServerEndpoint);
            }

            this.VerifyAuthentication(response);
            response.GetResponseStream().Close();
            AdapterHelper.SessionContextCookies = response.Cookies;

            return bindResponseBody;
        }
MS_OXCMAPIHTTPAdapter