Created
March 11, 2019 00:28
-
-
Save GDLMadushanka/f5e843e269a7561c940e5722bc9ce877 to your computer and use it in GitHub Desktop.
Calling a secure web service via C#
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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