I created a Java Service in webMethod’s Integration Server that should log something to the server.log
file. As it turns out, this is quite simple:
- Generate Java code for calling the internal Service
pub.flow.debugLog
by right-clicking on the Service in Software AG Designer and selecting “Generate Code…”, “For calling this service from another service”. The code gets copied to the clipboard automatically. -
Paste the code snippet into your Java Service. It may look like this:
// input IData input = IDataFactory.create(); IDataCursor inputCursor = input.getCursor(); IDataUtil.put( inputCursor, "message", "message" ); IDataUtil.put( inputCursor, "function", "function" ); IDataUtil.put( inputCursor, "level", "level" ); inputCursor.destroy(); // output IData output = IDataFactory.create(); try { output = Service.doInvoke( "pub.flow", "debugLog", input ); } catch( Exception e) {}
-
Now you’ll need a reference to the JAR file containing the needed classes (i.e.
com.wm.data.IData
,IDataCursor
,IDataUtil
, andcom.wm.app.b2b.server.Service
). The former can be found inclient.jar
(e.g.\SoftwareAG\eclipse\v36\plugins\com.webmethods.process.model.upgrade.impl_8.2.2.0000-0211\lib\client.jar
), the latter inwm-isserver.jar
(e.g.SoftwareAG\IntegrationServer\lib\wm-isserver.jar
). Add the JARs to your project’s build path and your done. Now you should be able to compile your project. I’ve created a short helper method for accessing the logging from a Java Service to get rid of the redundant code snippets:public static void logMessageToServerLog( IData pipeline, String message, String function, String level) throws ServiceException { IDataCursor inputCursor = pipeline.getCursor(); IDataUtil.put(inputCursor, "message", message); IDataUtil.put(inputCursor, "function", function); IDataUtil.put(inputCursor, "level", level); inputCursor.destroy(); try { Service.doInvoke("pub.flow", "debugLog", pipeline); } catch (Exception e) { throw new ServiceException(e.getMessage()); } }
Thanks Stefan.. this solution worked for me