Tuesday, October 5, 2010

Invoking IBM B2B Sterling Integrator WebServices with Security using Java Client

Web Services with Security
1) Generate self-sign certificate.
2) Assign certificate to Webservice and change protocol type to https while publishing webservice.
3) Import certificate into keytool using keytool of java.
4) Write a java client based on generated wsdl.

Command to import certificate into keytool
C:\>keytool -import -trustcacerts -alias HTTPSCertificateName -file D:\Projects\HTTPSCertificateName .cer -keystore "C:\Program Files\Java\jdk1.5.0_11\jre\lib\security\cacerts"
password: changeit

     (1) About command will import certificate into C:\Program Files\Java\jdk1.5.0_11\jre\lib\security\cacerts.
     (2) Make sure your C:\Program Files\Java\jdk1.5.0_11\jre\lib\security\cacerts file should update with latest date and time if it is successfuly   imported.

System Properties to set in Java code
    System.setProperty("javax.net.ssl.trustStore","C:\\Program Files\\Java\\jdk1.5.0_11\\jre\\lib\\security\\cacerts");
Note: changeit is the default password for java keytool.