Advanced Customization > Info*Engine User’s Guide > SOAP Services > Example Standalone Java SOAP Client > Generating DAOs
  
Generating DAOs
Data Access Objects (DAOs) are generated from Info*Engine tasks. Each DAO exposes one method signature per exposed Info*Engine task.
A DAO generated from the “org.myOrg.Math” class would expose the following public method signatures:
public int sum ( int x, int y ) throws Exception;
public double average ( double [] nums ) throws Exception;
And the following constructor (assuming a class name of “MathDAO”):
public MathDAO ( javax.resource.cci.Connection c, javax.
resource.cci.RecordFactory r );
Creation of the required instances of javax.resource.cci.Connection and javax.resource.cci.RecordFactory are discussed in Creating a Connection Handle.
Generated DAO methods may throw a java.lang.Exception. The reason such a generic exception is used is because the underlying classes used to issue a SOAP request can change. For example, the connection can be configured to use HTTP or JMS as the underlying protocol. An HTTP SOAP connection issues a java.net.ConnectionRefused exception if the HTTP service is unavailable, where a JMS SOAP connection issues a javax.jms.JMSException if a JMS-related error occurs.
DAO generation requires the following information:
endPoint
This is the location of the Info*Engine SOAP service. This value is optional and defaults to http://<host>/<Windchill>/servlet/RPC. Depending on your configuration, the default value may not be suitable, in which case you must explicitly specify this information. If credentials are required to access the service then the URL form of “http://<user>:<password>@host/...” should be used.
soapClass
This is the base class (type identifier) from which the DAO is generated. In our example this value is “org.myOrg.Math.”
fileSystem
This value points to a local directory where the root of your Java source tree is located.
package
This is the name of the Java package to which the generated source belongs.
class
This is the name of the class being generated.
There are two ways to generate a DAO: manually invoke a Java command to run the DAO generation tool, or use an Ant extension from an Ant build script.
For the purposes of this example assume the following is true:
You are developing the standalone Java client on the same host where the SOAP service is running.
The SOAP service requires the credentials username (wcadmin) and password (wcadmin).
The root of your Java source tree is /home/user/src.
To generate a DAO for the “org.myOrg.Math” class using a Java command line, invoke the following command (all on one line):
java com.infoengine.connector.dao.DAOGenerator endPoint=http://wcadmin:wcadmin@localhost/
Windchill/servlet/RPC soapClass=org.myOrg.Math fileSystem=/home/user/src package=org.
myOrg.Math class=MathDAO
An Ant build script that generates the DAO should look similar to the following code:
<?xml version="1.0"?>
<project name="generateDAO" default="all" basedir=".">


  <property name="wt.home" value="/opt/ptc/Windchill"/>


  <path id="cp">
    <pathelement location="$(wt.home)/codebase/WEB-INF/
lib/ieWeb.jar"/>

    <pathelement location="$(wt.home)/codebase/WEB-INF/
lib/ie3rdpartylibs.jar"/>
    <pathelement location="$(wt.home)/lib/servlet.jar"/>
  </path>


  <target name="declare">
    <taskdef name="generator" classname="com.infoengine.
connector.dao.AntDAOGenerator">
      <classpath refid="cp"/>
    </taskdef>
  </target>
  <target name="all" depends="declare">
    <generator
      endPoint="http://wcadmin:wcadmin@localhost/Windchill/
servlet/RPC"
      soapClass="org.myOrg.Math"
      fileSystem="/home/user/src"

package="org.myOrg.Math"

class="MathDAO"/>
  </target>


</project>
Using either method of DAO generation results in a Java source file being generated with a fully qualified class name of “org.myOrg.Math.MathDAO” (/home/user/src/org/myOrg/Math/MathDAO.java).