Out of the box a package can be installed on webMethods Integration Server via the Administrator’s Package Management GUI or using WmDeployer.
Following code snippet with allow you to install packages on a webMethods Integration Server through the usage of a custom developed java program, leveraging the internal wM codebase for introducing a package.
Java code snippet :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
/* * Usage: java -classpath <path_to_client_classes> PackageInstaller * host:<hostname> port:<port> user:<username> * pswd:<password> pckg:<package1>,<package2>,… * * The .zip extension for package names should be omitted * * If using a secure connection (https) to connect to your Integration Server * uncomment the following line in the connect() method below: * context.setSecure(true); */ import com.wm.app.b2b.client.*; import com.wm.util.*; import java.util.StringTokenizer; public class PackageInstaller { public static String hostName = null; public static String port = null; public static String userName = null; public static String password = null; public static String errorMsg = null; public static String packages = null; public static String tmpStr = null; Context context = null; public boolean connected = false; public static boolean secure = false; public static void main(String[] args) { /***********************************************************************/ /* Parse command line. The hostname, port, username and password must */ /* ALL be specified. */ /***********************************************************************/ errorMsg = “”; for (int iCtr = 0; iCtr < args.length; iCtr++) { if (args[iCtr].indexOf(“host:”) != -1) { hostName = args[iCtr].substring(5); if (hostName.length() < 1) errorMsg = errorMsg + “n No host name specified”; } else if (args[iCtr].indexOf(“port:”) != -1) { port = args[iCtr].substring(5); if (port.length() < 1) errorMsg = errorMsg + “n No port specified”; } else if (args[iCtr].indexOf(“user:”) != -1) { userName = args[iCtr].substring(5); if (userName.length() < 1) errorMsg = errorMsg + “n No user name specified”; } else if (args[iCtr].indexOf(“pswd:”) != -1) { password = args[iCtr].substring(5); if (password.length() < 1) errorMsg = errorMsg + “n No password specified”; } else if (args[iCtr].indexOf(“pckg:”) != -1) { packages = args[iCtr].substring(5); if (packages.length() < 1) errorMsg = errorMsg + “n No packages specified”; } else { errorMsg = errorMsg + “n Invalid parameter ‘” + args[iCtr] + “‘ specified.”; } } /***********************************************************************/ /* Display program usage instruction if there were any errors with the */ /* command line arguments. */ /***********************************************************************/ if ((errorMsg.length() > 0) || (hostName == null) || (port == null) || (userName == null) || (password == null) || (packages == null)) { System.out.println(” Usage: java -classpath ” + “<path_to_client_classes> PackageInstaller ” + “host:<hostname> port:<port> user:<username> ” + “pswd:<password> pckg:<package1>,<package2>,…n”); System.out.println(” Omit the .zip extension for package names”); if (errorMsg.length() > 0) System.out.println(” Errors encountered:” + errorMsg); System.exit(1); } //Create an instance of this class PackageInstaller packageInstaller = new PackageInstaller(); System.out.println(“Instantiated installer”); packageInstaller.connect(true); if(!packageInstaller.connected) { System.exit(1); } StringTokenizer st = new StringTokenizer(packages, “,”); while (st.hasMoreTokens()) { String packageName = st.nextToken(); packageInstaller.install(packageName + “.zip”); packageInstaller.activate(packageName); } System.exit(0); } public void connect(boolean dispMsg) { context = new Context(); try { /***********************************************/ /* Uncomment the following line if using https */ /***********************************************/ // context.setSecure(true); context.connect(hostName + “:” + port, userName, password); connected = true; } catch(ServiceException e) { if (dispMsg) { System.out.println(“Could not connect to ” + hostName + “:” + port); System.out.println(e.toString()); } connected = false; } } public void install(String packageName) { try { System.out.println(“Installing package ” + packageName + ” … “); Values input = new Values(); input.put(“file”, packageName); Values data = context.invoke(“wm.server.packages”, “packageInstall”, input); // System.out.println(“IData:n”); // System.out.println(data.toString()); } catch(ServiceException e) { System.out.println(e.toString()); System.exit(1); } } public void activate(String packageName) { try { System.out.println(“Activating package ” + packageName + ” … “); Values input = new Values(); input.put(“package”, packageName); Values data = context.invoke(“wm.server.packages”, “packageActivate”, input); // System.out.println(“IData:n”); // System.out.println(data.toString()); } catch(ServiceException e) { System.out.println(e.toString()); System.exit(1); } } public PackageInstaller() { System.out.println(); System.out.println(“******PackageInstaller utility*******”); System.out.println(); } } |
Remarks:
- When compiling and running the java program make sure to include files wm-isclient.jar and mail.jar in your class path. File wm-isclient.jar can found in the “common/lib” folder of an Integration Server whereas file mail.jar is localized in the “ext” sub folder of the “common/lib” folder.
- Usage of the PackageInstaller program is PackageInstaller host:<hostname> port:<port> user:<username> pswd:<password> pckg:<package1>,<package2>,…
The .zip extension for package names should be omitted - At this moment the java program is working with at least webMethods Integration Server v7.1.2. Specifications contained herein are potentially subject to change so use them at your own risk.
Author: Johan De Wulf