X.400 Java API - Example Application

Application Features

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

  • submit X.400 messages including attachments that are
    • IA5
    • General_Text (8859-1, 8859-2)
    • Binary
    • Message Body Part
  • retrieve X.400 messages
  • retrieve delivery reports
  • retrieve IPNs
  • submit IPN after successful retrieval of message

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.

Configuring the Application

The example application will work with the values configured by the quickconfig program. There are 3 main string variables that need to be adjusted. These are kept within the config.java class.

  • public static final String hostname = "dhcp-164";
  • public static final String domain = "isode.net";
  • public static final String country = "GB";

With these three values set to your own config then other values such as the p7_bind_oraddr, (used in binding to the message store) will be setup automatically.

So for example when running the example programs on a machine called "hay.isode.net" in a quickconfig configuration using country code "GB". The hostname would be "hay" the domain would be "isode.net",and the country would be "GB"

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 exmaple directory.

Compiling the Application

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

Unix

This command assumes that the JDK is installed in /usr/java/jdk1.5.0_08/bin/

# cd /opt/isode/share/x400sdk/example/java
# rm *.class ; rm com/isode/x400api/test/*.class
# /usr/java/jdk1.5.0_08/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.5.0_08

C:>
E:\jdk1.5.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

  • Presentation Address of the Store
  • P7 Credentials (simple)
    • Password
    • O/R Name
      • Directory Name (optional)
      • O/R address

The configuration of program-wide values are held at the start of the config.java file. By correctly setting the hostname, domain, country and type you should be able to send and receive X.400 emails fairly simply.

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 retrival:

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

  • Connection type to 1 (P3 submission only) or 2 (P3 submission and retrival)

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.

Copyright © 2008 Isode privacy   feedback Subscribe to our rss newsfeed