Server-Side Implementation for Outgoing Communication
The process of creating an outgoing communication channel involves the writing of a channel class, implementing its methods, and configuring it using the Partner Administration Tool.
This section provides you detailed information about the channel class and its methods.
HTTPSOut Class
An HTTPSOut
class must be written to enable
EC Communication Plug-In to send outgoing messages. The outgoing
communication class must implement the com.intentia.ec.shared.IMessageSender
interface.
This interface contains the following method:
public void send(InputStream messageStream, Manifest
manifest, Properties props)
The method declaration has the following arguments:
-
messageStream
– stream from where the message to be send can be read from -
manifest
– the delivery note containing metadata about the message -
props
– a container holding the properties for the send module
For example, a sample class named HTTPSOut
is created. The following code shows the HTTPSOut
class implement the IMessageSender
class.
public class HTTPSOut implements IMessageSender {
// Class fields goes here
}
For a complete code listing of HTTPSOut,
see Sample outgoing channel.
IMessageSender.send Method
To implement the send method, make sure the path and password
are dynamically configured through the system properties, and the
property values are extracted from the props argument. The properties
also show the host, port, and the path that is used to create an URL.
From the URL, get an HttpsURLConnection
(UC), which
should be configured to send data but not to receive data.
Since the EC HTTP server uses basic authentication, use Base64-encoding
to encode the user and password. To set the message as an HTTP parameter,
use the ClientHttpRequest
helper class. Finally,
post the created request. If everything is properly set up and if
you choose this channel, a message is sent using HTTPS.
Partner Administration Tool
Before adding the new channel to the system, write a Java class that can present a dialog in the Partner Administration Tool. The Partner Administration Tool allows you to set the properties for the channel. When you select a send communication protocol in the Partner Administration Tool, different dialogs appear depending on the chosen protocol.
Properties Dialog UI
To be able to set the corresponding properties for the outgoing
communication channel that you are about to create, you must create
a class displaying an equivalent dialog for the properties used in
the HTTPSOut
class. You will not create the dialog
itself, just the buttons, fields, and other for the widgets inside
the dialog.
A widget is a part of the Java SWT framework. The widget class is the abstract super class of all user interface objects. Widgets are created, disposed, and issue notifications to listeners when events occur which affect them.
The class containing the UI code must implement the interface com.intentia.ec.shared.IRoutingUI. It must contain the following methods:
-
createContent
– creates the content for this dialog -
setProperties
– sets the properties to be displayed -
getProperties
– returns the properties For this example, the sample class is namedHTTPSOutPanel
.
For a complete code listing of HTTPSOutPanel
, see Sample outgoing channel.
IRouting.createContent Method
The createContent
method contains code for
creating all the widgets needed. The argument is a composite widget
with a FlowLayout
added to it.
IRouting.setProperties Method
The setProperties
method contains code for
extracting the values of the given properties object and writing those
values to the correct text widget when you open the dialog in edit
mode. The following code shows how the value of the property HTTPSOut.HOST
is written to the host text widget:
txtHost.setText(props.getProperty(HTTPSOut.HOST, ""));
IRouting.getProperties Method
This method reads the values from the widgets and puts them into a Properties object and returns that object.