Logging to webMethod’s Integration Server log from a Java Service

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:

  1. 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.
  2. 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) {}
    
  3. Now you’ll need a reference to the JAR file containing the needed classes (i.e. com.wm.data.IData, IDataCursor, IDataUtil, and com.wm.app.b2b.server.Service). The former can be found in client.jar (e.g. \SoftwareAG\eclipse\v36\plugins\com.webmethods.process.model.upgrade.impl_8.2.2.0000-0211\lib\client.jar), the latter in wm-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());
        }
    }
    

1 thought on “Logging to webMethod’s Integration Server log from a Java Service”

Leave a Comment