Thin Clients implementieren

Verwendung

Das Thin Client Interface der INUBIT-Software ermöglicht es, Thin Clients in beliebigen Programmiersprachen zu erstellen. Diese Thin Clients sorgen für die Kommunikation verschiedener Quell- und Zielanwendungen mit der INUBIT Process Engine und werden für folgende Aufgaben eingesetzt:

  • Daten senden an eine INUBIT Process Engine, um Workflows im synchronen oder asynchronen Modus auszuführen.

  • Daten empfangen, die von Workflows auf einer INUBIT Process Engine verarbeitet wurden.

Verfügbares Protokoll

SOAP

Funktionsaufrufe des Thin Client Interface

Zur Kommunikation mit der INUBIT-Software gibt es folgende Funktionsaufrufe:

  • connectSOAP: Zur Verbindung mit der INUBIT Process Engine

  • login: Anmelden an der INUBIT Process Engine

  • logout: Abmelden von der INUBIT Process Engine

  • sendMessage: Asynchrones Senden von Nachrichten an die INUBIT Process Engine

  • receiveMessage: Asynchrones Empfangen von Nachrichten von der INUBIT Process Engine

  • convertMessage: Synchrones Aufrufen eines Workflows zur Verarbeitung von Nachrichten und Variablen in der INUBIT Process Engine

  • sendMessageUncompressed: Asynchrones Senden von Nachrichten an die INUBIT Process Engine

  • receiveMessageUncompressed: Asynchrones Empfangen von Nachrichten von der INUBIT Process Engine

  • convertMessageUncompressed: Synchrones Aufrufen eines Workflows zur Verarbeitung von Nachrichten in der INUBIT Process Engine

Alle Nachrichten werden base64-kodiert und komprimiert.

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;
}

Beispielimplementierung

So gehen Sie vor

  1. Installieren Sie eines der unterstützten Java Development Kits.

  2. Stellen Sie sicher, dass die Dateien jsse.jar und jnet.jar im Verzeichnis <inubit-installdir>/_jvm/lib/ext abgelegt sind.

  3. Kopieren Sie die Dateien ibis.jar und ibis_tools.jar aus dem Verzeichnis <workbench-installdir>/inubit/client/lib auf den Thin-Client-Rechner.
    Fügen Sie den Pfad der Dateien zum CLASSPATH hinzu.

  4. Wählen Sie ein Protokoll (SOAP) für die Implementierung Ihres Thin Clients aus, und implementieren Sie den Thin Client entsprechend.

Beispiel: Thin Client und 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>");
  }
}

Kompilieren

  • Windows

  • Unix

set IS_CLIB=<inubit-installdir>\client\lib
javac –classpath %IS_CLIB%\ibis.jar;%IS_CLIB%\ibis_tools.jar SoapClientDemo.java
export IS_CLIB=<workbench-installdir>/inubit/client/lib
javac –classpath $IS_CLIB/ibis.jar:$IS_CLIB/ibis_tools.jar SoapClientDemo.java

Demo starten

Zum Testen benötigen Sie einen Workflow mit einem INUBIT IS Connector, der als Input Listener konfiguriert ist.

  • Windows

  • 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
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