How to call in Java a .NET web service uses X509Certificate
591081Mar 30 2009 — edited Mar 31 2009Hi All,
I am tryimg to call a .NET web serrvice using (generating Java web service from WSDL file in Jdeveloper). This .NET web service requires a certificate verification, I have got the certificate (xxx.cer), and have installed in Java key store in client side but when I try to invoke the web service it gives me the error message "The page requires a client certificate".
Please anyboady has any idea about how to pass a certificate to web service using Java code?
my code is:
public static void main(String[] args)
{
try
{
UploadStub stub = new UploadStub();
//build java Certificate object.
InputStream certStream = new FileInputStream("........certificate.cer");
CertificateFactory cf = CertificateFactory.getInstance("X.509");
//This is Java Certificate
X509Certificate javaCert = (X509Certificate)cf.generateCertificate(certStream);
certStream.close();
Integer projectId = new Integer(0);
Integer datastoreId = new Integer(0);
String V_UserName = "";
String V_Password ="";
String V_fileName ="";
byte[] byteArr = null;
byteArr = readFile( V_fileName );
String returnVal = stub.SaveFile(projectId, datastoreId, V_UserName, V_Password, V_fileName, byteArr);
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
This is a sample code in .NET calling method
/*
objCert = X509Certificate.CreateFromCertFile("..\\..\\CertFiles\\certificate.cer");
uploadToWRRS.ClientCertificates.Add(objCert);
SaveFileResult = uploadToWRRS.SaveFile(ProjectID,DataStoreID,UserName,Password,fileName, BinaryFileContenys);
*/
Is there any method could we implement it in Java to verify the client certificate?
Thanks in advanced
Edited by: user588078 on Mar 31, 2009 10:00 AM