ebXML (www.ebxml.org) has a great opportunity to become major standard for an Internet global marketplace. ebXML is a set of modular specifications that define services for business process documentation, business communication, and business information persistence. These services can be used by any company in the world willing to establish a business relationship with its partners. In this sample, we will create ebXML Registry Information Model (RIM) XML Schema document that conforms to the ebXML Registry Information Model version 1.0 and ebXML Registry Services version 1.0. We use the XML Schema document to generate all Java classes required for RIM XML data-binding. An example containing a Submit Objects Request (SOR) ) XML document (see page 22 in ebXML Registry Services) will be processed and loaded into a RIM database. This process is called unmarshalling and it is implemented using Castor (www.castor.org) XML data-binding software for Java. To reference this sample we will use ebXML RIM-SOR as a sample name.
In this section we will explain how ebXML RIM-SOR unmarshalling solution is implemented.
The following steps are involved in a Castor unmarshalling procedure:
For example, for this sample we created rim directory that also contains schema subdirectory where final versions of XML Schema documents are located. Java compiler and ant automatically create additional subdirectories, java, java/sample, java/rim,and lib.
The following XML documents, programs and scripts are located in rim directory:
Later on when ant is executed using build.xml, java, java/sample, java/rim, and lib directories are created and their content is:
database.xml document contains database configuration details. It is used by Castor JDO database component that supports database transactions in two types of environment, client applications and J2EE servers. Make sure that your version of database.xml document contains your database configuration details (host name, port number, database connect string, database user id and password). Our database.xml example belongs to an Oracle database.
There is also schema directory that contains a SQL script rim.sql and XML Schema document copied from the rim directory by ant:
sqlplus userid/password@db_connect_string @rim.sql
where userid and password are the ones you specified in database.xml. database_connect_string is a database connect string specified in Oracle's tnsnames.ora.
The ebXML RIM-SOR XML Schema document formally defines ebXML RIM and SOR XML document structures and their elements data types.
The ebXML RIM-SOR XML Schema documents ( rim.xsd and global-codes.xsd) support an SOR XML document sample ( SubmitObjectsRequest.xml) and its DTD document ( rim.dtd). An XML file always starts with a prolog. The minimal prolog contains a declaration that identifies the document as an XML document. For example, <?xml version="1.0" encoding="UTF-8"?> . Ensure that the above documents start with a declaration you need. The ebXML RIM-SOR XML Schema is used by the Castor Source Generator to create Java classes for XML mapping.
Now when we have formal XML Schema definition for the ebXML RIM-SOR XML document (rim.xsd), we execute Castor Source Generator with the XML Schema document as an input. ebXML RIM-SOR XML software build is performed by ant and we simply run ant at this point. Before you run ant ensure that castor.dir, jdk.dir, and regexp.dir in build.xml have full directory paths that belong to your software configuration and jar file name in classpath for mortgage_classes must be changed to your Castor version (castor-0.9.4.1.jar is the one we are using).
Also, the CLASSPATH in the Control Panel's System/Environment (Windows NT/2000/XP) should be updated with the following directories if you installed Castor software in c:\:
Castor Source Generator generates all Java classes required for XML mapping. These classes are located in java/rim. They are used in programs for the ebXML RIM-SOR XML unmarshalling and marshalling.
mapping.xml is an XML document used for ebXML RIM-SOR XML mapping from the ebXML RIM-SOR Java classes to the RIM database tables.
Add a copy command for mapping.xml to the "copy" target in build.xml:
<copy file="${rim.dir}/mapping.xml" todir="${src.dir}/sample" />
Run ant again and ensure that it completes successfully.
Java program SubmitObjects.java unmarshals ebXML RIM-SOR XML document. All related RIM tables will be populated with data from the document.
build.xml has to be updated to include SubmitObjects.java
compilation:
Add the following line to "copy" target:
<copy file="${rim.dir}/SubmitObjects.java" todir="${src.dir}/sample"/>
Create new target "sample-classes" that will compile SubmitObjects.java:
<target name="sample-classes" depends="rim-jar">
<javac srcdir="${src.dir}/sample" destdir="${src.dir}/sample"
includes="SubmitObjects.java"
classpath="${lib.dir}/rim.jar;${castor.dir}/castor-0.9.4.1.jar;
${castor.dir}/classes12.zip;${jdk.dir}/tools.jar" />
</target>
Change default in build.xml project to "sample-classes".
Ensure that the database name in the following SubmitObjects.java statement:
_jdo.setDatabaseName( "ebdb" );
is the one you use. If it is "ebdb" leave it, otherwise change it to your name.
Run ant to compile SubmitObjects.java
Start submitobjects.bat script to execute ebXML RIM-SOR XML unmarshal program. Before you start the script, change all directory paths to ones that belong to your system configuration.