private void buttonSend_Click(object sender, EventArgs e) { if (checkBoxUpdateEWSHeader.Checked) { UpdateSOAPHeader(); } string sSOAPRequest = xmlEditorRequest.Text; string sSOAPResponse = ""; string sErrorResponse = ""; xmlEditorResponse.Text = ""; HighlightResponseGroupbox(false); buttonSend.Enabled = false; xmlEditorRequest.Enabled = false; this.Update(); CredentialHandler credentialHandler = CredentialHandler(); ClassSOAP oSOAP = new ClassSOAP(textBoxURL.Text, _logger, credentialHandler); SetSecurityProtocol(oSOAP); oSOAP.BypassWebProxy = checkBoxBypassProxySettings.Checked; if ((listViewHTTPHeaders.Items.Count > 0) || radioButtonOAuth.Checked) { // Add the HTTP headers List <string[]> headers = new List <string[]>(); foreach (ListViewItem item in listViewHTTPHeaders.Items) { string[] sHeader = new string[2]; sHeader[0] = item.Text; sHeader[1] = item.SubItems[1].Text; headers.Add(sHeader); } if (radioButtonOAuth.Checked) { oSOAP.AuthorizationHeader = String.Format("Bearer {0}", textBoxOAuthToken.Text); // Add OAuth token } oSOAP.HTTPHeaders = headers; } sSOAPResponse = oSOAP.SendRequest(sSOAPRequest, out sErrorResponse, RequestCookies()); xmlEditorResponse.Text = sSOAPResponse; if (!String.IsNullOrEmpty(sErrorResponse)) { HighlightResponseGroupbox(true, sErrorResponse); } // Store any cookies we have had returned PersistCookies(oSOAP.ResponseCookies); UpdateHTTPCookieControls(); UpdateHTTPHeaderControls(); buttonSend.Enabled = true; xmlEditorRequest.Enabled = true; }
private void SetSecurityProtocol(ClassSOAP oSOAP) { // Set security protocol as per form settings if (!(checkBoxTLS1_0.Checked || checkBoxTLS1_1.Checked || checkBoxTLS1_2.Checked)) { oSOAP.SecurityProtocol = SecurityProtocolType.Ssl3; return; } SecurityProtocolType securityProtocolType = 0; if (checkBoxTLS1_0.Checked) { securityProtocolType = securityProtocolType | SecurityProtocolType.Tls; } if (checkBoxTLS1_1.Checked) { securityProtocolType = securityProtocolType | SecurityProtocolType.Tls11; } if (checkBoxTLS1_2.Checked) { securityProtocolType = securityProtocolType | SecurityProtocolType.Tls12; } oSOAP.SecurityProtocol = securityProtocolType; }
private void buttonSend_Click(object sender, EventArgs e) { if (checkBoxUpdateEWSHeader.Checked) { UpdateSOAPHeader(); } string sSOAPRequest = xmlEditorRequest.Text; string sSOAPResponse = ""; string sErrorResponse = ""; xmlEditorResponse.Text = ""; HighlightResponseGroupbox(false); buttonSend.Enabled = false; bool bBasicAuthExistingSetting = (checkBoxForceBasicAuth.Checked && !radioButtonNoAuth.Checked); ClassSOAP oSOAP = null; oSOAP = null; LogCredentials(); if (radioButtonDefaultCredentials.Checked || (radioButtonSpecificCredentials.Checked && !checkBoxForceBasicAuth.Checked)) { oSOAP = new ClassSOAP(textBoxURL.Text, CurrentCredentials, _logger); } else if (radioButtonNoAuth.Checked) { oSOAP = new ClassSOAP(textBoxURL.Text, _logger); } else if (radioButtonCertificateAuthentication.Checked) { oSOAP = new ClassSOAP(textBoxURL.Text, _authCertificate, _logger); } else { oSOAP = new ClassSOAP(textBoxURL.Text, textBoxUsername.Text, textBoxPassword.Text, _logger); } SetSecurityProtocol(oSOAP); oSOAP.BypassWebProxy = checkBoxBypassProxySettings.Checked; if ((listViewHTTPHeaders.Items.Count > 0) || radioButtonOAuth.Checked) { // Add the HTTP headers List <string[]> headers = new List <string[]>(); foreach (ListViewItem item in listViewHTTPHeaders.Items) { string[] sHeader = new string[2]; sHeader[0] = item.Text; sHeader[1] = item.SubItems[1].Text; headers.Add(sHeader); } if (radioButtonOAuth.Checked) { oSOAP.AuthorizationHeader = String.Format("Bearer {0}", textBoxOAuthToken.Text); // Add OAuth token } oSOAP.HTTPHeaders = headers; } sSOAPResponse = oSOAP.SendRequest(sSOAPRequest, out sErrorResponse, RequestCookies()); xmlEditorResponse.Text = sSOAPResponse; if (!String.IsNullOrEmpty(sErrorResponse)) { HighlightResponseGroupbox(true, sErrorResponse); } // Store any cookies we have had returned PersistCookies(oSOAP.ResponseCookies); UpdateHTTPCookieControls(); UpdateHTTPHeaderControls(); buttonSend.Enabled = true; }