How to call a webservice (created in java) with ws security, they provided a certificate file , username & password, i tried using Web Services Enhancements (WSE) 3.0, Inherited the service proxy from Microsoft.Web.Services3.WebServicesClientProtocol used username password tocken
UsernameToken tocken = new UsernameToken("uname", "pwd");
Service.RequestSoapContext.Security.Tokens.Add(tocken);
got error "The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel."
Is it because of the client certificate ? I aslo tried
X509Certificate xCert = new X509Certificate();
xCert = X509Certificate.CreateFromCertFile("certificate_path.cer");
Service.ClientCertificates.Add(xCert);
I solved the issue its becuase of ssl certificate validation problem, used
UsernameToken token = new UsernameToken("uname", "pwd", PasswordOption.SendPlainText);
Service.RequestSoapContext.Security.Tokens.Add(token);
System.Net.ServicePointManager.CertificatePolicy = new TrustAllCertificatePolicy();
public class TrustAllCertificatePolicy : System.Net.ICertificatePolicy
{
public TrustAllCertificatePolicy()
{ }
public bool CheckValidationResult(ServicePoint sp,
X509Certificate cert, WebRequest req, int problem)
{
return true;
}
}