Isode Messaging APIs

Summary : This page describes how to use the Isode Java X.400 API to retrieve and submit messages using P7 into or out of a Message Store, or P3 directly into or out of an MTA.

X.400 Java API - Example Application

Application Features

The Java example does the following using the X.400 Java API

Note that there is only one example application to do all of this. You can use the same application to submit/retrieve using either P3 or P7, by passing the appropriate argument into X400msOpen(). This example adds several more complex attachments than the C and Tcl examples. In particular it constructs an X.400 Message to add as a message body part.

Full specification of the Java API is here

Messaging Configuration

Before running the P3/P7 applications you need run Mconsole to configure and run a messaging configuration including, (if you are using P7) an Isode Message Store.

You also need to configure a P3 or P7 user using the X.400 Mailbox View in Mconsole.

Configuring the Application

The example application needs to be configured to use the values you have configured using Mconsole for the MTA and P3/P7 Users. There are 2 main string variables that need to be adjusted. These are kept within the config.java class in com/isode/x400api/test/config.java.

Values used to bind to the p7 Store

    /** oraddress - makes up orname used to bind to the store */
    public static final String p7_bind_oraddr =
        "/CN=P7User1/O=" + hostname + "/PRMD=TestPRMD/ADMD=TestADMD/C=" + country + "/";

    /** dn - makes up orname used to bind to the store */
    public static final String p7_bind_dn = "c=eu";
    /** password */
    public static final String p7_credentials = "secret";
    /** presentation address of P7 Message Store */
    public static final String p7_pa
        = "\"3001\"/Internet=" + hostname + "." + domain + "+3001";
    public static final boolean use_opencheck = false;
    public static final String p7_ret_psw = "secret";

These are the values when binding to the P3 server

    /** oraddress - makes up orname used to bind to the store */
    public static final String p3oraddr = "/CN=P3User1/OU=Sales/O=" + hostname + "/PRMD=TestPRMD/ADMD=TestADMD/C=" + country + "/";
    /** dn - makes up orname used to bind to the store */
    public static final String p3dn = "c=eu";
    /** password */
    public static final String p3credentials = "p3secret";
    /** presentation address of P3 MTA channel */
    public static final String p3pa
        = "\"594\"/Internet=" + hostname + "." + domain;

Configuring Logging

Isode logging is controlled via xml files. Isode applications look for these xml files in ETCDIR (C:\Isode\etc on Windows and /etc/isode on unix.). Should an xml file called "logtailor.xml" be present, then this file will be used.

It is however possible to override this behaviour by manually specifying an xml file with a different name. In order to do this a session object must be created, and populated. Thus once a connection to the message store (or MTA) needs to occur before the following function call.

status = com.isode.x400api.X400ms.x400_ms_setstrdefault(session_obj,X400_att.X400_S_LOG_CONFIGURATION_FILE, "x400api.xml", -1);

Once called the X.400api will use the configuration information within the x400api.xml file. Logging xml files may be created or altered using the logconfig tool located within the BINDIR (C:\Program Files\Isode\bin on Windows, /opt/isode/bin on unix). There is an example x400api.xml file located within the x400api C example directory.

Compiling the Application

To build the application you must have a JDK installed. You should also make sure that there are no pre-compiled classes in your build tree.

Unix

This command assumes that the JDK is installed in /usr/lib/jvm/java/bin/

# cd /opt/isode/share/x400sdk/example/java
# rm *.class ; rm com/isode/x400api/test/*.class
# /usr/lib/jvm/java/bin/javac -sourcepath . -classpath -classpath /opt/isode/lib/java/classes/isode-x400.jar X400_test.java
# ./run_test.sh

Windows

This command assumes that the JDK is installed in E:\j2sdk1.8.0_08

C:>
E:\jdk1.8.0_08\bin\javac -sourcepath . -verbose -classpath
".;c:\progra~1\Isode\bin\java\classes\isode-x400.jar;C:\Program
Files\Isode\share\x400sdk\example\java" -g X400_test.java

(Note that the line should not be broken)

Submission via the Message Store (P7)

Connection to the Message Store

To connect to the Message Store you need

The configuration of program-wide values are held at the start of the config.java file.

However you must configure whether you are using P3 or P7. This value is a local variable declared and set just before the msopen() call. Use 0 for P7, 1 for P3 submission, and 2 for P3 submission and retrieval:

int type = 0;

Retrieval from the Message Store (P7)

Connection to the Message Store

This works in the same way as for Submission. There are no mandatory values to configure in the rcv_msg() part of the application.

Running the Application

Unix

To run the application you simply run the wrapper script from the command line. No arguments are required.

[root@dhcp-164 java]# ./run_test.sh 
X400_att.X400_API_VERSN = 14020000
Opened MS session successfully
Building message envelope
Building message content
Building message for message bodypart
Added recipient /CN=fwd msg orig/OU=lppt/O=dhcp-164/PRMD=TestPRMD/ADMD=TestADMD/C=GB/ successfully
Added recipient /CN=forwarded msg recip/O=dhcp-164/PRMD=TestPRMD/ADMD=TestADMD/C=GB/ successfully
Added recipient /CN=invalid/OU=lppt/O=dhcp-164/PRMD=TestPRMD/ADMD=TestADMD/C=GB/ successfully
Adding originator
Added recipient /CN=P7User1/OU=Sales/O=dhcp-164/PRMD=TestPRMD/ADMD=TestADMD/C=GB/to MS Message
Adding recipients
Added recipient /CN=P7User1/OU=Sales/O=dhcp-164/PRMD=TestPRMD/ADMD=TestADMD/C=GB/to MS Message
Added recipient /CN=invalid/O=GatewayMTA/PRMD=TestPRMD/ADMD=TestADMD/C=GB/to MS Message
Set security ID successfully/opt/isode/share
Set security ID DN successfullycn=AMHS Tester, cn=isode, c=GB
Set security ID PPHR successfullysecret
Submitted message successfully
Closed MS Session successfully

sent message
=================================================
Receive another message
=================================================
Did MS List successfully
No more list results, i = 1
Opened MS session successfully, 0 messages waiting
Set security ID successfully/opt/isode/share
Set security ID DN successfullycn=AMHS Tester, cn=isode, c=GB
Set security ID PPHR successfullysecret
x400_ms_msggetstart failed 30
Closed MS Session successfully

=================================================
Receive another message
=================================================
Did MS List successfully
No more list results, i = 1
Opened MS session successfully, 0 messages waiting
Set security ID successfully/opt/isode/share
Set security ID DN successfullycn=AMHS Tester, cn=isode, c=GB
Set security ID PPHR successfullysecret
x400_ms_msggetstart failed 30
Closed MS Session successfully

=================================================
Receive another message
=================================================
Did MS List successfully
No more list results, i = 1
Opened MS session successfully, 0 messages waiting
Set security ID successfully/opt/isode/share
Set security ID DN successfullycn=AMHS Tester, cn=isode, c=GB
Set security ID PPHR successfullysecret
x400_ms_msggetstart failed 30
Closed MS Session successfully

Windows


java  -Djava.library.path="C:\PROGRA~1\Isode\bin" -classpath .;
"c:\progra~1\Isode\bin\java\classes\isode-x400.jar;
C:\Program Files\Isode\share\x400sdk\example\java" -verbose:jni -Xms20m X400_test

Submission directly to the MTA (P3)

Connection to the MTA

Configuration of P3 Submission is similar to P7. You need to configure

Like the P7 configuration all MTA (P3 channel)connection values are held in program variables. These are dependant on the config.java class.

Retriving messages from the MTA

This works in the same way as for P3 Submission, except that to retrieve messages you must bind as a user who uses a p3 passive channel to perform delivery (i.e., a channel which is channel initiated, rather then queue manager initiated).

quickconfig sets up a p3 passive channel called p3server. It also configures a user called:

"/CN=P3User1/OU=Sales/O=" + hostname + "/PRMD=TestPRMD/ADMD=TestADMD/C=" + country + "/"

So in order to test P3 submission and delivery, set the type variable witin the config.class to 2. A message will be submitted to the P3User address. This will be routed to the p3server channel. The test program will then connect to this channel, and download the message.

All rights reserved © 2002 - 2024 Isode Ltd.