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" ); 
    // output IData output = IDataFactory.create(); 
        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); 
            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

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax