DataPower

DataPower

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
  • 1.  JAR Call

    Posted Thu June 01, 2023 08:48 AM
    Dears have a good day.
     
    I need your support in calling a java function from a JAR file using gateway script.
    I uploaded the jar file in local directory.
    and here is the JavaScript file used.
     
     
    var myJavaFunction = require('rsaEx.jar','Encryption');   var result = myJavaFunction.encryptRSA('MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxuurtZijGi1E26SXfSLm', 'test');    session.output.write(result.toString());
    but error occurred that the jar file is not utf-8 encoded
     
    GatewayScript processing Error 'Error: The 'local:///rsaEx.jar' script file is not encoded in UTF-8. Invalid character at line 1, position 3. In file 'gatewayscript:///datapower.js' line:348, stack:Error
     
    Using another approach including the java module is not supported.
    Here is the JavaScript using the java module.
     
     
    var java = require('java'); java.classpath.push('local://rsaEx.jar');       // Use classes and methods from the JAR file var myClass = java.import('rsaEx.Encryption'); var result = myClass.encryptRSA('MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxuurtZijGi1E26SXfSLmEXInJ7On', 'test');   session.output.write(result);
     
    and here is the error occurred
     
    GatewayScript processing Error 'Error: Unable to open the script module file 'java' In file 'gatewayscript:///datapower.js' line:301

    Your fast response is highly appreciated.



    Riham Lamei

    Banking Automation/Integration Engineer

    +201223796831

    Smart Village (Building B 115), Giza, Egypt

     





  • 2.  RE: JAR Call

    Posted Thu June 01, 2023 09:37 PM

    Riham,

    I was anxiously awaiting a response from someone, because I thought this would be cool.  But, I'd be surprised if DataPower supports this.

    Did you see somewhere that it can?



    ------------------------------
    Joseph Morgan
    ------------------------------