I need to use a SOAP and WSDL based web service. SOAP (https) uses login, password and certificate for authorization. PHP example:
<?
...
$client->authtype = 'certificate';
$client->decode_utf8 = 0;
$client->soap_defencoding = 'UTF-8';
$client->certRequest['sslcertfile'] = 'path_to_cert.crt';
$client->certRequest['sslkeyfile'] = 'path_to_private.key';
$client->certRequest['cainfofile'] = 'path_to_cacert.pem';
$client->call("method");
...
?>
How can I do this in C #? I add a Service Reference to VS2008 and try:
var ya = new YAPI.APIPortClient();
ya.Open();
ya.PingAPI();
Exception exception:
Failed to establish trust for SSL / TLS secure channel with authority 'service url'.
Try the following:
var ya = new YAPI.APIPortClient();
ya.ClientCredentials.UserName.UserName = "login";
ya.ClientCredentials.UserName.Password = "pass";
ya.ClientCredentials.ClientCertificate.Certificate = new X509Certificate2(@"path_to_cert.crt");
ya.Open();
ya.PingAPI();
and catch the same exception. What do I need to do to get authorized? Thanks for answers. Sorry for the bad english :)
user168302
source
share