Skip to content

Instantly share code, notes, and snippets.

@GDLMadushanka
Created March 11, 2019 00:28
Show Gist options
  • Save GDLMadushanka/f5e843e269a7561c940e5722bc9ce877 to your computer and use it in GitHub Desktop.
Save GDLMadushanka/f5e843e269a7561c940e5722bc9ce877 to your computer and use it in GitHub Desktop.
Calling a secure web service via C#
private void button2_Click(object sender, EventArgs e)
{
echoSecured.echoSecuredPortTypeClient client = new echoSecured.echoSecuredPortTypeClient("echoSecuredHttpsSoap11Endpoint");
CallProxyApplication.echoSecured.echoStringRequest echoStringRequest = new echoSecured.echoStringRequest();
CallProxyApplication.echoSecured.echoStringResponse echoStringResponse = new echoSecured.echoStringResponse();
client.ClientCredentials.UserName.UserName = "admin";
client.ClientCredentials.UserName.Password = "admin";
echoStringRequest.@in = textBox2.Text;
try
{
// Ignore certificate check
ServicePointManager.ServerCertificateValidationCallback =
delegate (object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; };
String response = client.echoString(echoStringRequest.@in);
richTextBox2.Text = response;
}
catch (Exception ex)
{
richTextBox2.Text = ex.Message;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment