Skip to main content

skip to main content

developerWorks  >  Information Management  >

Get started using IBM Data Studio Developer with Informix Dynamic Server

Create, test, and deploy IDS applications

developerWorks
Go to the previous pagePage 4 of 10 Go to the next page

Document options
PDF format - Fits A4 and Letter

PDF - Fits A4 and Letter
1831 KB (44 pages)

Get Adobe® Reader®

Discuss

Sample code


My developerWorks needs you!

Connect to your technical community


Rate this tutorial

Help us improve this content


Create Web services with IDS

One of the features of Data Studio is the ability to create Data Web Services. You can expose your database operations (invocation of a stored procedure, select, insert, or update statements) easily as Web services with a few clicks of a button, and then Data Studio takes care of creating the Web application for you. It can create both SOAP and 'REST'ful services for you. You can then deploy the Web application (that includes the Web service classes and the WSDL file) on a Web server, and you are done.

You need to create a new project first. Perform the following the steps:

  1. Go to File > New > Project > Data Development Project.
  2. Name the project ifmxproject, and click Next.
  3. Use the connection name that you created for your Informix database.
  4. Answer Yes to Open Associated Perspective.

Now you are ready to create Web services. Perform the following steps:

  1. In the Data Project Explorer, select the project that you have just created.
  2. Right-click on Web Services, and select New Web Service.
  3. Name the Web service ifmxservice, and click Finish.
  4. Right-click on the Web Service, and click New Operation.
  5. Type in an SQL statement to select three fields from the cust table, as shown in Figure 8:

    Figure 8. Creating an operation
    Creating an operation

  6. Select Validate to confirm that the statement is valid. Leave the name as "Operation1".
  7. Pick the Web service ifmxservice from the previous step, and then click Build and Deploy.
  8. This tutorial uses WebSphere Application Server Community Edition 2.1. The steps in the next section list the configuration steps for WebSphere Application Server Community Edition 2.1. This example also uses the REST scenario, instead of SOAP.
  9. Click on Finish. This creates all the necessary components for you.

    Figure 9. Deploying a Web service
    Deploying a Web service

Configure WebSphere Application Server Community Edition

A video on configuring WebSphere Application Server Community Edition

Refer to this video to see how to set up WebSphere Application Server Community Edition in one step.

This section includes a set of steps for how to configure WebSphere Application Server Community Edition 2.1 to make it work with Informix and then get the Web service running.

  1. The installer comes with Data Studio Developer 2.1 when the option is enabled. It is found in the <install dir>/dsdev/bin directory. Run the installer.
  2. After installing the server, bring up the server by selecting IBM WebSphere > Application Server Community Edition > Start the server.
  3. Open a web browser and type in the default url: http://127.0.0.1:8080/console/portal
  4. The default username/password to log in: system/manager.

    Figure 10. WebSphere Application Server Community Edition Administration Console
    WebSphere Application Server Community Edition Administration Console

    Follow the steps below if you do not want the workbench to register the database connection with the Web server.
    1. Since IBM Data Server Driver for JDBC and SQLJ is already registered, you have an option to add Informix JDBC Driver if you desire to use that driver instead. Add the ifxjdbc.jar file to the WebSphere Application Server Community Edition repository. In order to do this in the Administrative Console, select Console Navigation > Services > Repository.
    2. In the Repository Viewer, fill in the fields, and click Install. Use the following values for the fields:
      1. Pick up ifxjdbc.jar from the appropriate location.
      2. In the Group field, specify com.informix.jdbc.
      3. In the Artifact field, specify ifxjdbc.
      4. In the Version field, specify 11.0.
      5. In the Type field, specify jar.

        Figure 11. Driver JAR file
        Driver JAR file

    3. Create an IDS database pool by using the Geronimo database pool wizard. Each Web service that you deploy on the server must use a unique database pool.
    4. Name the database pool and select Informix as the database type.
    5. Select the following driver JAR file: com.informix.jdbc/ifxjdbc/11.0/jar.
    6. The next step is to set up the database pool connection. Select Database Pools under Services folder on the left screen.
    7. Create a new database pool by clicking on Using the Geronimo database pool wizard.
    8. Specify the name of the database pool and database type, then click on Next.
    9. Fill in the following fields (as illustrated in Figure 12):
      • JDBC Driver Class: com.informix.jdbc.IfxDriver
      • Driver Jar: com.informix.jdbc/ifxjdbc/11/jar
      • DB User Name: the username used to connect to the database
      • DB Password: <DB password>
      • Confirm Password: <confirm password>
      • Port: <The server port>
      • dbservername: <The database server name>
      • Database: gsdb
      • Host: <The host name>


      Figure 12. Parameters
      Parameters


      (Click here to see a larger image of Figure 12.)
    10. After pressing Next, verify that the JDBC Connect URL is valid.
    11. Optionally, you can specify values for parameters of the connection pool.
  5. Record the value of the groupID and artifactID parameters for the database connection pool. You must specify these values when you deploy the Web service that uses this database connection pool. The values of the groupID and artifactID parameters are case-sensitive. In this example, the groupID is console.dbpool and the artifactID is gs_db.
  6. Click Finish and deploy, and make sure you can connect to your database.

Ensure the geronimo-web.xml file generated by the Data Studio has the matching information in the highlighted portion.


Listing 1.
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-2.0.1" 
xmlns:naming="http://geronimo.apache.org/xml/ns/naming-1.2" 
xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.2">
  <dep:environment>
    <dep:dependencies>
      <dep:dependency>
        <dep:groupId>console.dbpool</dep:groupId>
        <dep:artifactId>GSDB</dep:artifactId>
        <dep:version>1.0</dep:version>
        <dep:type>rar</dep:type>
      </dep:dependency>
    </dep:dependencies>
  </dep:environment>
  <context-root>ifmxprojectifmxservice</context-root>
  <naming:resource-ref>
    <naming:ref-name>jdbc/ifmxservice</naming:ref-name>
    <naming:pattern>
      <naming:groupId>console.dbpool</naming:groupId>
      <naming:artifactId>GSDB</naming:artifactId>
      <naming:name>GSDB</naming:name>
    </naming:pattern>
  </naming:resource-ref>
</web-app>

Create the Web archive file (WAR file) to be deployed to the Web server. To do this, complete the following steps:

  1. Switch to the Java perspective by going to Window > Open Perspective > Java.
  2. For your Web service ifmxservice and your project ifmxproject, there is a Web project called "ifmxprojectifmxserviceWeb" that has been created.
  3. Generate the WAR File by clicking on the project, then right-click and select Export.
  4. Select WAR file, and then click Next.

    Figure 13. Export into WAR file
    Export into WAR file

  5. Create the file in an appropriate location to be used later in the WebSphere Application Server Community Edition deployment panel.

    Figure 14. Export to a local system
    Export to a local system

Now, switch back to the Administration Console and deploy the WAR file by performing the following steps:

  1. Log back in to the Administration Console.
  2. Go to Applications > Deploy New, and pick the WAR file created earlier.

    Figure 15. Deploy WAR file
    Deploy WAR file

If you have used all of the defaults as mentioned in the tutorial, use the following URL in a browser window to look at the service in action: http://localhost:8080/ifmxprojectifmxservice/rest/ifmxservice/Operation1/. If your Web applications port is not 8080, you may have to change the port to match your environment.


Go to the previous pagePage 4 of 10 Go to the next page