The WSIT Tutorial

ProcedureTo Build, Deploy, and Run the basicWSTX Example

  1. Download the sample kit for this example from https://wsit-docs.dev.java.net/releases/1-0-FCS/wsittutorial.zip.

  2. Ensure that properties that point to your local 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 GlassFish and at least Ant 1.6.5 have been installed and are on the path.

      GlassFish includes Ant 1.6.5, which can be found in theas-install/lib/ant/bin directory.

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

    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 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 GlassFish installation.

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

    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
      
  4. Register the GlassFish server instances (domain1 and domain2) in the NetBeans IDE.

    1. If the Sun Java System Application Server (domain1) is already registered, go to Step 4g. If it is not, go to Step 4b.

    2. In the Runtime tab, right-click Servers and select Add Server.

      The Add Server Instance dialog appears.

    3. Choose the server (Sun Java System Application Server) from the menu and give it a descriptive name, such as Sun Java System Application Server - domain1 (Server), and then press Next.

    4. Press the Browse button, navigate to the location where the GlassFish server is installed, then press Choose.

    5. Select domain1 from the menu, then press Next.

    6. Type the admin account password (adminadmin) in the Admin Password field, then press Finish.

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

    7. Right-click Servers and select Add Server.

      The Add Server Instance dialog appears.

    8. Choose the server (Sun Java System Application Server) from the menu and give it a descriptive name, such as Sun Java System Application Server - domain2 (Client), and then press Next.

    9. Press the Browse button, navigate to the location where the GlassFish server is installed, then press Choose.

    10. Select domain2 from the menu, then press Next.

    11. Type the admin account password (adminadmin) in the Admin Password field, then press Finish. The server instance you just registered is the one in which you will run the web service client (SampleServiceClient).

  5. Associate the SampleService web service with the appropriate instance (domain1) of the GlassFish server.

    1. Select File, then Open Project.

    2. Browse to the tut-install/wsittutorial/examples/wstx/basicWSTX/ directory, select the SampleService project, and select Open Project Folder.

    3. In the Projects tab, right-click SampleService, select Properties, then select the Run category.

    4. Use the Server menu to point to the Sun Java System Application Server, the default domain, or the Glassfish server instance (domain1) you registered in Step 4.

    5. Click OK.

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

    This operation creates file SampleService\SampleService-war\web\WEB-INF\wsit-wstx.sample.service.Simple.xml, in which the transaction attribute settings for the SampleService-war are stored.

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

    1. In the Projects tab, open the SampleService-war project.

    2. Open the Web Services node.

    3. Right-click Simple and select Edit Web Service Attributes.

    4. Select the WSIT tab and open the Operation node and then the method node in each section. Select the indicated setting for each of the following operations from the Transaction menu:

      • Set init to Required.

      • Set publishRequired to Required.

      • Set publishSupports to Supported.

      • Set verify to Required.

      • Set getMessage to Required.

      Figure 12–3 shows how this is done for the publishRequired operation.

      Figure 12–3 Setting the Transaction Attribute for the publishRequired Method

      Screen shot showing how to set the transaction attribute
for the publishRequired method

    5. Click OK.

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

  7. Deploy the SampleService web service.

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

  8. Register the SampleServiceClient client with the appropriate instance (domain2) of the GlassFish server.

    1. Select File, then Open Project.

    2. Browse to the tut-install/wsittutorial/examples/wstx/basicWSTX/ directory, select the SampleServiceClient project, and select Open Project Folder.

    3. In the Projects tab, right-click SampleServiceClient, select Properties, then select the Run category.

    4. Use the Server menu to point to domain2.

    5. Click OK.

  9. Create web service references for the client (two web service clients, a simpleServlet and a CMT EJB client) and generate the WSDL for both.

    1. In the Projects tab, right-click SampleServiceClient, select New, then select Web Service Client.

    2. Click Browse next to the Project field. The Browse Web Services dialog is displayed.

    3. Open 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.

    6. Click Browse next to the Project field. The Browse Web Services dialog is displayed.

    7. Open 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.

    10. Click Browse next to the Project field. The Browse Web Services dialog is displayed.

    11. Open SampleService-ejb, select LibraryFacadeWebServiceBean, then click OK.

    12. In the Package field, type wstx.sample.library, then click Finish.

  10. (Optional) 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 SimpleService 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 SimpleAsCMTEjb to do the same for the LibraryFacadeWebServiceBean client.

  11. Deploy and run the client. Right-click SampleClient and select Run Project.

    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 Figure 12–4.

    Figure 12–4 basicWSTX Results

    Screen shot of basicWSTX results