iBatis DAO with Web Services Wizard

Tools
Tools covers the tools and utilities you use to work with Teradata and its supporting ecosystem. You'll find information on everything from the Teradata Eclipse plug-in to load/extract tools.
Teradata Employee

iBatis DAO with Web Services Wizard

The iBatis DAO with Web Services Wizard will generate a Web Service from an iBatis SQL Map. The wizard derives all of the information needed from the iBatis SQL Map to generate the following components to create a Web service:

  • DAO (Data Access Object)
  • WSDL (Web Service Definition Language)
  • XSD (XML Schema Definition)
  • Spring Configuration files

The wizard will then use the Eclipse Web Tools Platform (WTP) and Apache Axis to generate the server and client classes for the Web service. The generated classes will include code that supports Query Bands via the Teradata Access Session Manager.

Unknown Object

Prerequisite for this Article

If you have not worked through the guide Getting Started with Teradata Plug-in for Eclipse,do so now before you continue. You should use the single download, Eclipse IDE for Java EE Developers for your installed Eclipse. This download includes additional Eclipse packages for Web application development.

Install Server

An application server must be installed in Eclipse. Open the Web perspective in Eclipse and go to the Servers view. Right click in the view and select the New->Server drop down menu.

Select the Apache Tomcat v6.0 Server in the New Server Wizard.

Install the new Apache Tomcat server if required. Follow all installation instructions from Apache and Eclipse.

Create Teradata Project

The iBatis DAO with Web Services Wizard requires a Teradata Project. First, if you have not worked through the article Create a Teradata Project using the Teradata Plug-in for Eclipse, do so now before you continue. Now, select File->New->Other.. from the top menu bar in Eclipse. Then select the Teradata Wizards->Teradata Project from the pop-up dialog. Enter "EmployeeProject" for the name of your new Project in the Teradata Project Wizard. Once this is done select the Finish button in the Wizard and a Teradata Project will be created.

Create an iBatis SQL Map

The iBatis DAO with Web Services Wizard uses an iBatis SQL Map file to create a DAO and Web service. Create the EmployeeMapping.xml iBatis XML map using the instructions and the examples in the article Create an iBatis SQL Map with Teradata Plug-in for Eclipse.

Launch Wizard

Once you have created the EmployeeMapping.xml you can launch the iBatis DAO Web Services Wizard by right clicking on the iBatis XML file from the Package Explorer and selecting the "Create a DAO" menu option.

iBatis DAO with Web Services Wizard

The First page of the Wizard defines the new DAO and options to create a Web Service.

Select the following options:

  • Create WSDL
  • Create Web Service
  • Use Teradata Session Manager
  • Save Password

Now hit the Next button

iBatis DAO Methods

The iBatis DAO Methods Wizard Page allows you to select which SQL actions from your iBatis Map file to be used in your Web service. You can change your return type from returning a single result set object to returning a list instead. Once you hit the next button Your DAO and Web Service Definition files will be created.

Web Service Creation

The next page is the standard WTP Web services Wizard. Set your Client to test. Once you hit the Finish button your Stubs and Skeletons will be created for your Web Service. The Implementation stub will be modified to use the new DAO you just created.

Web ServiceClient

The Web Service client will come up ready to use and connected to your Teradata database.

Generated Code

iBatis DAO with Web Services Wizard using an iBatis XML Map has generated all of the components for your Web service application including:

  • DAO (Data Access Object) is the Java class using the iBatis XML map to call your SQL for your Web service
  • WSDL (Web Service Definition Language) is used with Apache Axis to generate the server and client classes for the Web service.
  • Schema Objects to represent the input and output parameters
  • The Server Skeleton that handles the Web service communications plumbing
  • Teradata Service class calls iBatis DAO with the Teradata Session Manager and provides a static Accessor method to the Application context.
  • Spring Configuration files which wires your Web service to your DAO
  • A Client Proxy for running the Web service

The Friday Night Project articles from the developer exchange describe how each generated component works individually and with each other.  It is now up to you to continue to develop your Web service application with the generated code and framework which has been provided to you.

Appendix A

Trouble Shooting:

You can try the following if you are having trouble bringing up your web service or test client:

Make sure you installed the following version of JEE Eclipse:

http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/helios/R/eclips...

Start your Eclipse clean (See Article below)

http://www.eclipsezone.com/eclipse/forums/t61566.html

If you are getting HTTP Status 404 in your client, try re-making the client by launching the WTP Generate Client Wizard from your WSDL file in  (Your Original Teradata Project)/WebContent/wsdl/ directory.

If you are still having problems bringing up your web service or test client, manually clean your workspace server.

  • Stop your server and clean it in Eclipse
  • Exit Eclipse
  • Erase the following file:

C:\(Your Work Space) \.metadata\.plugins\org.eclipse.wst.server.core\publish.xml

  • Erase the following folders:

C:\(Your Work Space) \.metadata\.plugins\org.eclipse.wst.server.core\publish

C:\(Your Work Space) \.metadata\.plugins\org.eclipse.wst.server.core\tmp0

  • Start Eclipse
15 REPLIES
Teradata Employee

Re: iBatis DAO with Web Services Wizard

You can use the iBatis DAO with Web Services Wizard to create TestNG Unit Tests for your iBatis DAO.
Teradata Employee

Re: iBatis DAO with Web Services Wizard

I found if you increase the memory Eclipse uses by increasing the memory settings in the eclipse.ini file, the Web Services Wizard runs much better. (The more the better)

-startup
plugins/org.eclipse.equinox.launcher_1.1.1.R36x_v20101122_1400.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.2.R36x_v20101222
-product
org.eclipse.epp.package.jee.product
--launcher.defaultAction
openFile
--launcher.XXMaxPermSize
512M
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
512m
--launcher.defaultAction
openFile
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Xms512m
-Xmx1024m
Teradata Employee

Re: iBatis DAO with Web Services Wizard

If you have a 64 bit machine, you should take advantage of it. The WTP is very memory intensive when creating a Web Service. You can increase how much memory is used with Eclipse if you install the 64 bit versions of Java, Eclipse and the Apache Tom cat server. Once you have done all this, you can increase the memory settings beyond the limitations of a 32 bit machine in your eclipse.ini file.

-startup
plugins/org.eclipse.equinox.launcher_1.1.1.R36x_v20101122_1400.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.2.R36x_v20101222
-product
org.eclipse.epp.package.jee.product
--launcher.defaultAction
openFile
--launcher.XXMaxPermSize
1024M
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
1024m
--launcher.defaultAction
openFile
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Xms512m
-Xmx2048m

Re: iBatis DAO with Web Services Wizard

Very elaborate. Thanks!
Teradata Employee

Re: iBatis DAO with Web Services Wizard

WSDL and JSP validation can slow down the Web Services Wizard in Eclipse. You can disable WSDL and JSP validation in Eclipse preferences if validation is slowing your system down.

Re: iBatis DAO with Web Services Wizard

That's a lot of research that went into this! My neighbor works for Teradata and it usually takes me a few days to realize how much more he knows than I do!

Term Life
Insurance

Re: iBatis DAO with Web Services Wizard

How can this approach be extended to display a result set with more than one row of data? While the response can be seen using the Web Service Explorer , it is not being displayed. The following message is displayed in the result window :

Result
[empl.domain.service.schema.SqlmultilpeDomainObj1@274b6f, empl.domain.service.schema.SqlmultilpeDomainObj1@149a3, empl.domain.service.schema.SqlmultilpeDomainObj1@10211]

The actual result should display Employee No, DeptNo, Gender, Occupation, Name for three different Employees.
Teradata Employee

Re: iBatis DAO with Web Services Wizard

The client launched by the Web Service Wizard is not a refined client. This client is for testing. It is up to you to complete your client. You can try adding a toString Method to both your client and server Employee Schema classes.
These classes are in the ....service.schema package. Add a HTML break to the String returned from your toString Method so each employee is listed on a new line from your client.

Re: iBatis DAO with Web Services Wizard

Good article!
Just one question regarding the enterprise JAVA application design:
What is the best way to design the data access layer to work with Teradata?
I mean, Teradata is not a common relational database even though should consider an ORM framework to work with? Or it’s better to just use a JDBC itself?

I’m facing some “entityNotFoundExceptions” in production through EJB/JPA(Hibernate)...

Regards!