Saturday, July 22, 2017

Consuming SSL Web service with certificate using oracle SOA 12c

lately , we have received WSDL from client with SSL and certificate and we try to consume this  web service we have faced the following exception :

javax.xml.ws.WebServiceException: javax.net.ssl.SSLKeyException: Hostname verification failed

we quick solve this issue by the following steps :

Servers -> server name -> Configuration SSL tab -> Advanced -> Change Hostname Verification dropdown to None

then we face this exception :
sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
our understand was , we need to import certificate into weblogic keystror and  to do that we went to keystrore tab in weblogic to get the path of trust store and we surprised because the concept in 12c is different about 11g . in 11g you will see physical paths while in 12c became urls .

after some research we understood that we have to add the certificate to system\trust keystore from em



but the error did not change so we back to 11g concept and we try . the steps as follow :


  • create key store using keytool
  • import Root,intermediate,client certificate to this key store
  • adding this commands to file set domainenv                                                                                        set JAVA_OPTIONS=%-Djavax.net.ssl.trustStore=fullpath -Djavax.net.ssl.trustStorepassword=yourpassword
  • restart weblogic
and that's all !

Note : after we finish this solution we discovered oracle link that may help to solve first solution issue by the following :


  1. Open FMW_HOME/user_projects/domains/WLS_SOA/bin/setDomainEnv.sh.
  2. In EXTRA_JAVA_PROPERTIES:
    Replace:
    • -Djavax.net.ssl.trustStore=%WL_HOME%\server\lib\DemoTrust.jks
    With:
    • -Djavax.net.ssl.trustStore=kss://system/trust -Djavax.net.ssl.trustStoreType=kss

but i did not try it so i strongly advice to try this first before go to 11g approach .


Note2 : a i did not include keytool commands to create keystore and import certificate because it's available everywhere .



finally , i would like to thank my colleague Mohannad click here for his support .






Saturday, February 18, 2017

Integration with Knet Payment Gateway - Pin Pad Device

in this article series i will suggest way to control Pinpad Device (payment through device) from ADF application . the story started when we received java Api (jar) from knet payment Gateway (Kuwait payment gateway ) , with target to implement it through ADF application .

first approach was implementing it using java applet which not worked because java Applet became out dated . we looked to alternative solutions but we failed .

later , we found implementation using windows service (hosting Wcf over windows Service) but the challenge still exist because we don't have dll . so we converted the jar to dll .  

the proposed solution have the following steps :

  1. Convert jar to dll (to convert library from java technology to .net)
  2. develop WCF Service (rest) over windows 
  3. import the Dll and execute the payment process through web operation
  4. run and start windows Service
  5. call the service from java script
Below the details :

conversion library from jar to dll :
we searched a lot to find the appropriate too to do this task . until we found ikvm tool which enable you to convert your jars to dlls and exe (check this)  after downloading and unzipping it you can execute this task using the following command line :

ikvmc your jar.jar

after execution you will find your dll in the same directory , did you find it ? good job 😏
now let us go to the next step .

 Hosting WCF on windows service :
this approach suggested by Microsoft to host web services on end user PC with full privileges to access user resources and hardware check this.

  Create java script Caller :

in this part i will show how to create java script code that should be used to call Rest service that hosted on ADF application  . below sample for it .

<script type="text/javascript">
       function test() 
             {
                var xhttp = new XMLHttpRequest();
                xhttp.open("POST", "http://localhost:8000/ServiceModelSamples/service/knetPayment",                     true) ;
               xhttp.setRequestHeader("Content-type", "application/json");
               
                xhttp.onload = function (e) 
                   {
                      if (xhttp.readyState === 4) 
                           {
                              if (xhttp.status === 200) 
                                       {
                                           alert(xhttp.responseText);
                                        } 
                              else 
                                        {
                                           alert(xhttp.statusText);
                                         }
                               }
                     };
              xhttp.onerror = function (e) 
                    {
                       alert(xhttp.responseText);
                    };
              xhttp.send('{"Amount":"10"}');
              alert("3");
           
         }



    </script>


Enjoy !