Re-use your own existing Java code in a Java Service in webMethods Integration Server

Modularization is an important concept of programming. So, when I wanted to create a Java Service in webMethods’ Integration Server today, I wanted to re-use my existing Java code that already provided the feature I wanted to publish as a Service. However, this is not as easy as it sounds 😉 Here are the steps you need to perform to get your already existing Java code working in a Java Service:

  1. Compile and bundle your external Java project into a JAR file, e.g. using Apache Ant.
  2. Copy this JAR file into the subfolder code\jars\ of your package on Integration Server and reload the package. Example path: [...]\SoftwareAG\IntegrationServer\packages\YOURPACKAGE\code\jars\. Now, IS is able to use the JAR and automatically puts it into the package’s CLASSPATH.
  3. Copy the JAR file into the subfolder lib\ of your local Java project (in your local Eclipse workspace) and add it to the Eclipse project’s CLASSPATH, e.g. by adding <classpathentry kind="lib" path="lib/MyExternalProject.jar"/> to .classpath. Now, Software AG Designer (i.e. Eclipse) is able to resolve the external classes and can compile the code correctly, provide code completion etc.
  4. import the needed packages from your external project and use the classes in your code. Here’s some example code from the resulting Java Service:

    package XML.Services;
    import com.wm...; // all webMethods imports
    import; // import from your external project
    public final class ValidateXML_SVC
       * The primary method for the Java service
       * @param pipeline
       *            The IData pipeline
       * @throws ServiceException
      public static final void ValidateXML(IData pipeline) throws ServiceException
        xml = ISPipelineHelper.getInputParameter(pipeline, "xmlStream");
        schema = ISPipelineHelper.getInputParameter(pipeline, "schemaStream");
      // --- <<IS-BEGIN-SHARED-SOURCE-AREA>> ---  
      private static InputStream xml;
      private static InputStream schema;
      private static boolean isValid;
      private static String validationError;
      private static void validateXML() throws ServiceException 
        isValid = true;
        validationError = "";
        // now you can use your own classes
        SaxXmlValidator validator = new SaxXmlValidator(xml, schema);
        catch (XmlNotValidException e) 
          isValid = false;
          validationError = e.getMessage();
        catch (Exception e)
          throw new ServiceException(e);
      // --- <<IS-END-SHARED-SOURCE-AREA>> ---

2 thoughts on “Re-use your own existing Java code in a Java Service in webMethods Integration Server”

  1. Hi Stefan,

    thanks for the infos. For WM it’s hard to find useful information. The official documentation is imo very disappointing. Currently I battle with 9.12 for the same problem and without much success. Only for pt 3 I need some help. BTW I use IntelliJ for the jar-file and the Designer for service development. Where do I find the Eclipse CLASSPATH and the lib\ folder?


  2. Hi Martin,

    I’m talking about the Java project that SAG Desginer creates for you. If you program a Java Service, there will automatically be a Java project where the sources are stored in your SAG workspace. In this folder you’ll find .classpath and lib. Perhaps you need to enable Local Versioning in SAG Designer by right clicking on the IS Package and selecting the appropriate item in the context menu.

    Best regards,

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](

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

Here is some inline `code`.

For more help see