Implementing Thin Clients
Usage
The thin client interface of the INUBIT software allows you to create thin clients in any programming language. These thin clients ensure the communication of different source and target applications with the INUBIT Process Engine and are used for the following tasks:
-
Sending data to an INUBIT Process Engine to execute workflows in synchronous or asynchronous mode.
-
Receiving data that has been processed by workflows on an INUBIT Process Engine.
Available protocol
SOAP
Refer to https://www.w3.org/TR/SOAP
Function Calls Offered by the Thin Client Interface
The following function calls can be used to communicate with the INUBIT software:
-
connectSOAP
: For connecting to the INUBIT Process Engine -
login
: Login INUBIT Process Engine -
logout
: Logout INUBIT Process Engine -
sendMessage
: Sending messages asynchronously to the INUBIT Process Engine. -
receiveMessage
: Receiving messages asynchronously from the INUBIT Process Engine. -
convertMessage
: Synchronously calling up a workflow for processing messages and variables in the INUBIT Process Engine. -
sendMessageUncompressed
: Sending messages asynchronously to the INUBIT Process Engine. -
receiveMessageUncompressed
: Receiving messages asynchronously from the INUBIT Process Engine. -
convertMessageUncompressed
: Synchronously calling up a workflow for processing messages in the INUBIT Process Engine.
All messages are base64-encoded and compressed.
Listing
package com.inubit.ibis.utils;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Properties;
import com.inubit.ibis.plugins.utils.IBISPluginPropertyHandler;
/**
* This interface implements INUBIT Java Thin Client.
* ThinClientSOAP uses SOAP protocol to communicate with INUBIT.
*
*/
public interface I_ThinClient {
/**
* Connect a ThinClient to the INUBIT via the XML-RPC protocol.
* @param urlString IBIS servlet URL
* @param trustStoreFile trusted keystore, only for HTTPS relevant
* @throws InubitException
*/
public void connectXMLRPC(String urlString, String trustStoreFile) throws InubitException;
/**
* Connect a ThinClient to the INUBIT via the XML-RPC protocol.
*
* @param urlString IBIS servlet URL
* @param trustStoreFile trusted keystore, only for HTTPS relevant
* @param keyStoreFile keystore file, only for HTTPS client authentication relevant
* @param keyStorePassword keystore password, only for HTTPS client authentication relevant
* @throws InubitException
*/
public void connectXMLRPC(String urlString, String trustStoreFile, String keyStoreFile, String keyStorePassword) throws InubitException;
/**
* Connect a ThinClient to the INUBIT via the SOAP protocol.
* Only ThinClientSOAP implements this method.
*
* @param urlString INUBIT servlet URL
* @param trustStoreFile trusted keystore, only for HTTPS relevant
* @throws InubitException
*/
public void connectSOAP(String urlString, String trustStoreFile) throws InubitException;
/**
* Connect a ThinClient to the INUBIT via the SOAP protocol.
* Only ThinClientSOAP implements this method.
*
* @param urlString INUBIT servlet URL
* @param trustStoreFile trusted keystore, only for HTTPS relevant
* @param keyStoreFile keystore file, only for HTTPS relevant, client authentication
* @param keyStorePassword keystore password, only for HTTPS relevant, client authentication
* @throws InubitException
*/
public void connectSOAP(String urlString, String trustStoreFile, String keyStoreFile, String keyStorePassword) throws InubitException;
/**
* Login a user to use a workflow on an INUBIT
*
* @param username the username for the login
* @param password the password for the login
* @return the id of the user
* @throws InubitException
*/
public String login(String username, String password) throws InubitException;
/**
* Logout user from INUBIT
* @throws InubitException
*/
public void logout() throws InubitException;
/**
* Send a message asynchronously to INUBIT, compressed data transport.
*
* @param fileName the name of the file sent to the INUBIT
* @param inputMessageStream the input message with the data to be sent to the INUBIT
* @throws InubitException
*/
public void sendMessage(String fileName, InputStream inputMessageStream) throws InubitException;
/**
* Receive asynchronously processed message from INUBIT, compressed data transport.
*
* @param fileName the name of the file to be downloaded from the INUBIT
* @param outputMessageStream the output stream to write the data from the server to
* @throws InubitException
*/
public void receiveMessage(String fileName, OutputStream outputMessageStream) throws InubitException;
/**
* Synchronous message processing by IS, compressed data transport.
*
* @param inputMessageStreams the input message with the data to be sent to the INUBIT
* @param outputMessageStreams the output streams to write the data from the server to
* @throws InubitException
*/
public void convertMessage(InputStream[] inputMessageStreams, OutputStream[] outputMessageStreams) throws InubitException;
/**
* Synchronous message processing by INUBIT, compressed data transport.
*
* @param inputMessageStreams the input message with the data to be sent to the INUBIT
* @param outputMessageStreams the output streams to write the data from the server
* @param variables can optionally be defined for workflow execution
* @throws InubitException
*/
public void convertMessage(InputStream[] inputMessageStreams,
OutputStream[] outputMessageStreams, IBISPluginPropertyHandler variables) throws InubitException;
/**
* Send a message asynchronously to IS, uncompressed data transport.
*
* @param fileName the name of the file sent to the IS
* @param inputMessageStream the input message with the data to be sent to the INUBIT
* @throws InubitException
*/
public void sendMessageUncompressed(String fileName, InputStream inputMessageStream) throws InubitException;
/**
* Receive asynchronous processed message from IS, uncompressed data transport.
*
* @param fileName the name of the file to be downloaded from the INUBIT
* @param outputMessageStream the output stream to write the data from the server to
* @throws InubitException
*
*/
public void receiveMessageUncompressed(String fileName, OutputStream outputMessageStream) throws InubitException;
/**
* Synchronous message processing by IS, uncompressed data transport.
*
* @param inputMessageStreams the input message with the data to be sent to the IS
* @param outputMessageStreams the output streams to write the data from the server
* @throws InubitException
*/
public void convertMessageUncompressed(InputStream[] inputMessageStreams, OutputStream[] outputMessageStreams) throws InubitException;
/**
* Returns the object data as serialized XML string
*
* @param user
* @param objectName
* @param objectType
* @return object
* @throws InubitException
*/
public String getObject(String user, String objectName, String objectType) throws InubitException;
}
Sample Implementation
Proceed as follows
-
Install one of the supported Java Development Kits.
-
Make sure that the files
jsse.jar
andjnet.jar
are placed in the directory<inubit-installdir>/_jvm/lib/ext
. -
Copy the files
ibis.jar
andibis_tools.jar
from the directory<inubit-installdir>/inubit/client/lib
to the thin client computer. Enter the path of the files to theCLASSPATH
. -
Choose a protocol (SOAP) for implementation of your thin client and implement the thin client accordingly.
Example: Thin Client and SOAP
package com.inubit.ibis.demo;
import java.io.*;
import com.inubit.ibis.utils.I_ThinClient;
import com.inubit.ibis.utils.ThinClientSOAP;
public class SoapClientDemo {
public static void main(String[] args) {
// check the parameters
if (args.length < 4) {
usage();
System.exit(1);
}
// set the upload and download files
File uploadFile = new File(args[0]);
File downloadFile = new File(args[1]);
// set the login name and password of the Input System Connector
String login = args[2];
String password = args[3];
// create the SOAP thin client
I_ThinClient client = new ThinClientSOAP();
try {
// connect the client to the local IS
client.connectSOAP("\https://<server>:<port>/ibis/servlet/IBISSoapServlet", null);
// login to the Input System Connector
String userId = client.login(login, password);
FileInputStream in = new FileInputStream(uploadFile);
FileOutputStream out = new FileOutputStream(downloadFile);
// perform a synchronous operation
client.convertMessage(new InputStream[]{in}, new OutputStream[]{out});
// logout the thin client
client.logout();
System.out.println("SOAP demo finished successfully");
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Displays the usage parameters.
*/
private static void usage() {
System.out.println("Usage: java " +
SoapClientDemo.class.getName() +
" <uploadFile> <downloadFile> <login> <password>");
}
}
Compiling
-
Windows
set IS_CLIB=<inubit-installdir>\client\lib javac –classpath %IS_CLIB%\ibis.jar;%IS_CLIB%\ibis_tools.jar SoapClientDemo.java
-
Unix
export IS_CLIB=<inubit-installdir>/inubit/client/lib javac –classpath $IS_CLIB/ibis.jar:$IS_CLIB/ibis_tools.jar SoapClientDemo.java
Starting demo
For testing, use a workflow with an INUBIT IS Connector configured as an input listener.
-
Windows
java –cp .;%IS_CLIB%\ibis.jar;%IS_CLIB%\ibis_tools.jar -Dsax.driver=org.apache.xerces.parsers.SAXParser com.inubit.ibis.demo.SoapClientDemo input.xml output.csv catalog-in inubit
-
Unix
java –cp .:$IS_CLIB/ibis.jar:$IS_CLIB/ibis_tools.jar -Dsax.driver=org.apache.xerces.parsers.SAXParser com.inubit.ibis.demo.SoapClientDemo input.xml output.csv catalog-in inubit