17.3. Building, Deploying and Running the basicWSTX Example

Complete the following steps to configure your environment then build, deploy, and run the basicWSTX example.

To Build, Deploy, and Run the basicWSTX Example

  1. Download the sample kit for this example from https://wsit-docs.java.net/releases/1.2/wsittutorial.zip.
  2. Ensure that properties that point to your local Application Server (or GlassFish) and WSIT Tutorial installations have been set.
    1. Copy file tut-install/wsittutorial/examples/bp-project/build.properties.sample to file tut-install/wsittutorial/examples/bp-project/build.properties.
    2. Set the javaee.home and wsit.tutorial.home properties in the file tut-install/wsittutorial/examples/bp-project/build.properties.
    3. Ensure that Application Server (or GlassFish) and at least Ant 1.6.5 have been installed and are on the path.

      Application Server (or GlassFish) includes Ant 1.6.5, which can be found in the as-install/lib/ant/bin directory.

  3. Set up your environment to run the basicWSTX example.

    To configure your environment to run the example:

    1. Change to the tut-install/wsittutorial/examples/wstx/basicWSTX/SampleService directory:
      cd tut-install/wsittutorial/examples/wstx/basicWSTX/SampleService
    2. Issue the following command to configure your environment to run the example:
      ant setup

    This step performs the following configuration tasks for you:

    • Starts domain1.

    • Creates the resources (jms/Queue and XATransaction jms/ConnectionFactory) used in the example.

    • Creates and sets up two Application Server (or GlassFish) domains.

      The domains can be created either on one machine or on two different machines. These steps show you how to do it on one machine. The first domain, domain1, is created as part of the Application Server (or GlassFish) installation.

    • Establishes trust between the two domains by installing each domain’s s1as security certificate in the other domain’s truststore.

  4. Use the NetBeans IDE to create a database connection.
    1. Start the NetBeans IDE.
    2. In the Services tab, right-click Databases and select New Connection.

      The New Database Connection dialog displays.

    3. Select Java DB (Network) as name
    4. Type localhost in the Host field.
    5. Type 1527 in the Port field.
    6. Type wstxSampleDB in the Database field.
    7. Type app in the User Name field.
    8. Type app in the Password field.
    9. Select the Remember password checkbox.
    10. Click OK.
  5. Register the Application Server (or GlassFish) server instances (domain1 and domain2) in the NetBeans IDE.
    1. If Sun Java System Application Server (domain1) is already registered, go to Step 5j. If it is not, go to Step 4b.
    2. In the Services tab, right-click Servers, and select Add Server.

      The Add Server Instance dialog appears.

    3. Choose the server (Sun Java System Application Server (or GlassFish V2) from the drop-down list and give it a descriptive name, such as Sun Java System Application Server - domain1 (Server), and then click Next.

      The Platform Location dialog displays.

    4. ClickBrowse, navigate to the location where the Application Server (or GlassFish server) is installed, then click Choose.
    5. Make sure that the Register Local Default Domain radio button has been selected.
    6. Use the drop-down list to select domain1, then click Next.

      The Domain Admin Login Info dialog displays.

    7. Type admin in the Admin Username field.
    8. Type adminadmin in the Admin Password field.
    9. Click Finish.

      The server instance you just registered is the one in which you will run the web service (SampleService).

    10. Right-click Servers and select Add Server.

      The Add Server Instance dialog appears.

    11. Choose the server (Sun Java System Application Server (or GlassFish V2) from the drop-down list and give it a descriptive name, such as Sun Java System Application Server - domain2 (Client), and then click Next.

      The Platform Location dialog displays.

    12. ClickBrowse, navigate to the location where the Application Server (or GlassFish server) is installed, then click Choose.
    13. Make sure that the Register Local Default Domain radio button has been selected.
    14. Use the drop-down list to select domain2, then click Next.

      The Domain Admin Login Info dialog displays.

    15. Type admin in the Admin Username field.
    16. Type adminadmin in the Admin Password field.
    17. Click Finish.

      The server instance you just registered is the one in which you will run the web service client (SampleServiceClient).

  6. Open the SampleService project and associate the SampleService web service with the appropriate instance (domain1) of the Application Server (or GlassFish server).
    1. Select File, then Open Project.
    2. Browse to the tut-install/wsittutorial/examples/wstx/basicWSTX/ directory and select the SampleService project.
    3. Select the Open as Main Project check box.
    4. Select the Open Required Projects check box.
    5. Click Open Project.

      The SampleService project and two required projects, SampleService-ejb and SampleService-war, are opened and are shown in the Projects tab.

    6. In the Projects tab, right-click SampleService, select Properties, then select the Run category.
    7. Use the Server drop-down list to point to the default domain, domain1, for the Application Server (or Glassfish) server instance you registered in Step 5.
    8. Click OK.
  7. Resolve references to or add the Toplink Essentials Library to the SampleService-ejb project.

    The SampleService-ejb project references the Toplink Essentials Library Module that is included with NetBeans IDE. To verify whether the reference to this library is resolved in your NetBeans IDE environment:

    1. Right click the SampleService-ejb project and select Properties.
    2. Select the Libraries category.

      You should see Toplink Essentials in the Compile-time Libraries pane of the Compile tab.

    3. If you do not see the library, click Add Library to display the Add Library dialog.
    4. Locate and select Toplink Essentials and then click Add Library.

      You should now see Toplink Essentials in the Compile-time Libraries pane of the Compile tab.

    5. Click OK.

    To verify that you have Toplink Essentials library in NetBeans IDE, select Tools and then Library Manager. You should see "Toplink Essentials" in the left pane. If you don't, you can create the library yourself using the two Toplink JAR files in the Application Server (or GlassFish) lib directory and then resolve the reference to the newly created library.

  8. Set the proper transaction attributes for each mapping (wsdl:binding /wsdl:operation) in the SimpleService-war web service.

    To set the transaction attributes for the SampleService-war web service:

    1. In the Projects tab, expand the SampleService-war node.
    2. Expand the Web Services node.
    3. Right-click Simple Service and select Edit Web Service Attributes.
    4. In the Quality of Service tab, expand the five operation nodes and then expand the method nodes under each operation node. Use the Transaction drop-down list to set the appropriate transaction attribute for each method:
      • Set init to Required.

      • Set publishRequired to Required.

      • Set publishSupports to Supported.

      • Set verify to Required.

      • Set getMessage to Required.

      If any other operations are displayed, ignore them.

    5. Click OK.

      Transaction attributes for SampleServiceASCMTEJB do not need to be set; EJB 3.0 transaction attributes are used.

    The transaction attribute settings for the SampleService-war are stored in the file SampleService\SampleService-war\web\WEB-INF\wsit-wstx.sample.service.Simple.xml.

  9. Deploy the SampleService web service.

    Right-click SampleService and select Undeploy and Deploy. NetBeans IDE will start domain1 and deploy the web service to that domain.

  10. Register the SampleServiceClient client with the appropriate instance (domain2) of the Application Server (or GlassFish) server.
    1. Select File, then Open Project.
    2. Browse to the tut-install/wsittutorial/examples/wstx/basicWSTX/ directory and select the SampleServiceClient project.
    3. Select the Open as Main Project check box.
    4. Select the Open Required Projects check box.
    5. Click Open Project.

      The SampleServiceClient project is opened and is displayed in the Projects tab.

    6. In the Projects tab, right-click SampleServiceClient, select Properties, then select the Run category.
    7. Use the Server drop-down list to point to domain2.
    8. Click OK.
  11. Create web service references for the client (three web service clients, a simpleServlet and two CMT EJB clients) and generate the WSDL for all.
    1. In the Projects tab, right-click SampleServiceClient, select New, then select Web Service Client.

      The New Web Service Client dialog displays.

    2. Click Browse next to the Project field.

      The Browse Web Services dialog displays.

    3. Expand SampleService-war, select Simple, then click OK.
    4. In the Package field, type wstx.sample.client, then click Finish.
    5. Right-click SampleServiceClient, select New, then select Web Service Client.

      The New Web Service Client dialog displays.

    6. Click Browse next to the Project field.

      The Browse Web Services dialog displays.

    7. Expand SampleService-ejb, select SimpleAsCMTEjb, then click OK.
    8. In the Package field, type wstx.sample.ejbclient, then click Finish.
    9. Right-click SampleServiceClient, select New, then select Web Service Client.

      The New Web Service Client dialog displays.

    10. Click Browse next to the Project field.

      The New Web Service Client dialog displays.

    11. Expand SampleService-ejb, select LibraryFacadeWebServiceBean, then click OK.
    12. In the Package field, type wstx.sample.library, then click Finish.
  12. If transaction attributes for the servlet (see Step 7) or CMT EJB web service have changed, those services must be deployed and client web service references refreshed to get new web service attributes.

    To refresh the client web service references for this example:

    1. In the Projects tab, open the SampleServiceClient, then open Web Service References.
    2. Right-click Simple and select Refresh Client to refresh the client node and regenerate the WSDL for the simpleServlet.
    3. Right-click SimpleAsCMTEjb to do the same for the CMT EJB client.
    4. Right-click LibraryFacadeWebServiceBean to do the same for the LibraryFacadeWebServiceBean client.
  13. Deploy and run the client.

    Right-click SampleServiceClient and select Run.

    NetBeans IDE will start domain2, deploy the servlet and EJB CMT clients to that domain, then display the results for both in a pop-up browser window, as shown in basicWSTX Results.

    basicWSTX Results
    Screen shot of basicWSTX results

Terms of Use; Privacy Policy; Copyright ©2013-2014 (revision 20140418.2d69abc)
 
 
Close
loading
Please Confirm
Close