Tuesday, June 11, 2024

Using Batik Library for SVG to PNG Conversion in Software AG Integration Server

 

Prerequisites:

  1. Ensure you have the necessary JAR files for Apache Batik and its dependencies.
  2. The JAR files must be placed in the code/jars directory of your Integration Server package.

Required JAR Files:

Ensure you have the following JAR files:

  • batik-all-1.9.jar
  • xalan-2.7.2.jar
  • commons-logging-1.2.jar
  • commons-io-2.8.0.jar
  • xmlgraphics-commons-2.2.jar
to avoid any error copy all downloaded JARs into folder code/jars in the package

Steps to Integrate Batik Library

  1. Download JAR Files:

    • You can manually download the required JAR files from this link https://archive.apache.org/dist/xmlgraphics/batik/source/batik-src-1.9.zip
  2. Place JAR Files in Integration Server:

    • Copy the downloaded JAR files to the code/jars directory of your Integration Server package.
           

  1. Restart Integration Server (Optional):

    • Restart the Integration Server to load the new libraries.

Java Service Code for SVG to PNG Conversion

Ensure your Java service is correctly set up to use the Batik library. Here's the code:


import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.OutputStream; import org.apache.batik.transcoder.TranscoderInput; import org.apache.batik.transcoder.TranscoderOutput; import org.apache.batik.transcoder.image.PNGTranscoder; import com.wm.data.IData; import com.wm.data.IDataCursor; import com.wm.data.IDataUtil; import com.wm.app.b2b.server.ServiceException; public static final void convertSVGToPNG(IData pipeline) throws ServiceException { // Retrieve input parameters from the pipeline IDataCursor cursor = pipeline.getCursor(); String svgFilePath = IDataUtil.getString(cursor, "svgFilePath"); String pngFilePath = IDataUtil.getString(cursor, "pngFilePath"); cursor.destroy(); if (svgFilePath == null || pngFilePath == null) { throw new ServiceException("Input parameters 'svgFilePath' and 'pngFilePath' are required."); } FileInputStream inputStream = null; FileOutputStream outputStream = null; try { // Create a transcoder instance PNGTranscoder transcoder = new PNGTranscoder(); // Set the input File svgFile = new File(svgFilePath); inputStream = new FileInputStream(svgFile); TranscoderInput input = new TranscoderInput(inputStream); // Set the output File pngFile = new File(pngFilePath); outputStream = new FileOutputStream(pngFile); TranscoderOutput output = new TranscoderOutput(outputStream); // Perform the transcoding transcoder.transcode(input, output); } catch (Exception e) { throw new ServiceException("Error converting SVG to PNG: " + e.getMessage(), e); } finally { try { if (inputStream != null) inputStream.close(); if (outputStream != null) { outputStream.flush(); outputStream.close(); } } catch (Exception e) { // Log the error if any e.printStackTrace(); } } }

Test the Service

  1. Create a Flow Service:

    • Create a flow service that calls the convertSVGToPNG Java service.
    • Map the input parameters (svgFilePath and pngFilePath).
  2. Execute the Flow Service:

    • Run the flow service and check if the PNG file is generated correctly.

By following these steps, you should be able to convert SVG files to PNG using the Batik library in Software AG Integration Server without encountering the WriteAdapter error. If you face any issues, ensure that all dependencies are correctly placed and the server is properly restarted.

Monday, May 20, 2024

Configure JDBC connection with Microsoft SQL Server (Integration Server 10.7)

Connection  to MSSQL database is not out of box feature .To apply it first you need to download the JDBC Driver jar from Microsoft site  then you need add it under lib folder and restart the server . 

Lib Path is : C:\yourSAGHome\IntegrationServer\instances\default\lib\jars

After the restart the server will be able to load the new jar and make it available for future use .

Steps in Details

1- 


2-Unzip the file then copy file mssql-jdbc-11.2.3.jre8 to the following paths (in each integration server node) .

        C:\yourSAGHome\IntegrationServer\lib C:\yourSAGHome\IntegrationServer\instances\default\lib\jars

3-Restart the server 4-login to the server and go to Adapters –> webMethods Adapter for JDBC --> 5- click Configure New Connection link then choose webMethods Adapter for JDBC Connection

6-fill configuration details :   

               


                                            
7-Click test connection and enable connect


Enjoy Your SQL Connection !


Sunday, May 19, 2024

Fix issue : Unable to locate or start compiler in webmethod integration server 10.7

In some cases when we try to compile java service using save the following error are showing up :

The source was saved, but was not compiled due to the following errors:

com.wm.app.b2b.server.ServiceException: [ISS.0014.9116] Unable to locate or start compiler



 Resolution : 
Remove the command watt.server.compile=C:\sag107\jvm\jvm\bin\javac -classpath {0} -d {1} {2} from extended settings to enforce use default compiler



Reference :

watt.server.compile
Specifies the compiler command that Integration Server uses to compile Java services that are developed using
Designer

, For example, javac -classpath {0} -d {1} {2}This compiler command is also used from the jcode utility. If this property is omitted or empty, the server uses the JVM internal Java compile tool to compile Java services.