Jump to: navigation, search

JAXWS/SmokeTestScenarios/

Prereqs

  • Download and Install the Apache CXF Runtime (version 2.2.x) from the Apache CXF downloads page.
  • Configure the Apache CXF Runtime in the Window > Preferences > Web Services > CXF 2.x Web Services preference page.
  • Install the latest version of Apache Tomcat.

Scenario 1: Create a Bottom Up Web Service

  1. Create a Dynamic Web Project.
  2. Import the wtp/Converter.java class into the source folder of the Dynamic Web Project.
  3. Right-click on the Converter.java class and select Web Services > Create Web Service to open the Web Service wizard.
  4. Move the service slider to the Test service stage.
  5. In the Service Configuration: section:
    1. Verify that Apache Tomcat is the selected Server:.
    2. Select the Web service runtime: link and select Apache CXF 2.x in the resulting dialog.
    3. Verify that the selected Service project: is the Dynamic Web Project that contains the Converter.java class.
  6. Click Next >.
  7. Select the Use a Service Endpoint Interface: checkbox.
  8. Select the Create an SEI radio button.
  9. Enter a name for the SEI in the text field.
  10. Click the Select All button.
  11. Click Finish. After creating the service, deploying to and starting Tomcat, the wizard will launch the Web Services Explorer.
  12. In the Web Services Explorer
    1. Under Operations in the right hand pane, click on farenheitToCelsius.
    2. In the float entry field enter a 72.0 and click Go.
    3. The Status pane should display return (float): 22.222221

Scenario 2: Create a Top Down Web Service

  1. Create a Dynamic Web Project.
  2. Import the AreaService.wsdl into the Dynamic Web Project's WebContent folder.
  3. Right-click on the AreaService.wsdl file and select Web Services > Generate Java bean skeleton to open the Web Service wizard.
  4. Move the service slider to the Test service stage.
  5. In the Service Configuration: section:
    1. Verify that Apache Tomcat is the selected Server:.
    2. Select the Web service runtime: link and select Apache CXF 2.x in the resulting dialog.
    3. Verify that the selected Service project: is the Dynamic Web Project that contains the AreaService.wsdl file.
  6. Click Finish.
  7. Open the generated implementation class org.tempuri.areaservice.AreaServiceImpl.
    1. Replace the generated method body of the calculateRectArea() method to return parameters.getHeight() * parameters.getWidth() and save the class.
    2. Restart the Apache Tomcat server.
  8. In the Web Services Explorer
    1. Under Operations in the right hand pane, click on CalculateRectArea.
    2. In the width float entry field enter 12.0 and in the height float entry field enter 2.0 and click Go.
    3. The Status pane should display area (float): 24.0

Scenario 3: Create a Web Service Client

  1. Create a Dynamic Web Project.
  2. Open the Web Service Client wizard by selecting File > New > Other... > Web Services > Web Service Client from the top level menu.
  3. Enter the URI of a remote WSDL file in the Service Definition: text field. e.g. the URL or the AreaService.wsdl from Scenario 2 after deploying to Tomcat
  4. Drop the client slider to Develop client.
  5. In the Configuration: section:
    1. Select Apache CXF 2.x as the Web service runtime.
    2. Verify that the selected Client project: is the Dynamic Web Project that you created in step 1.
  6. Click Finish. The generated client will include a main() method that when run will connect to the remote service and invoke every operation on that remote service.
  7. Navigate to the source folder of the Dynamic Web Project and open the generated client in the Java editor.
  8. Edit the generated arguments that will be used to invoke the operations on the service.
  9. To run the client right-click on the client in the Project Explorer and select Run As > Java Application.

Scenario 4: Annotation Properties View

  1. Create a Dynamic Web Project.
  2. Import the wtp/Converter.java class into the source folder of the Dynamic Web Project.
  3. Open the Converter.java class in the Java editor.
  4. Open the Annotation Properties view by selecting Window > Show View > Other... > JAX-WS > Annotation Properties from the top level menu.
  5. Select the Converter top level type. The view will react to the selection in the Java editor and display the applicable annotations.
  6. Select the checkbox in the Values column for the @javax.jws.WebService annotation to add the annotation to the type.
  7. Expand the @javax.jws.WebService annotation entry in the Annotations Properties view.
    1. Edit the element values using the cell editors and hit return. Confirm that the values are updated and saved in the Java editor.

Scenario 5: Annotation Validation and Quick Fixes

  1. Create a Dynamic Web Project.
  2. Right-click on the Dynamic Web Project and select Properties.
  3. On the Java Compiler > Annotation Processing properties page select Enable annotation processing.
  4. Import the wtp/Converter.java class into the source folder of the Dynamic Web Project.
  5. Open the Converter.java class in the Java editor.
  6. Annotate the class with the @javax.jws.WebService annotation.
  7. Change the public modifier of the farenheitToCelsius method to private.
  8. Add the @javax.jws.WebMethod annotation to the farenheitToCelsius method.
  9. Confirm that the @WebMethod annotation is not allowed on non-public methods error message is displayed in the Markers view and that the farenheitToCelsius method is highlighted in the Java editor.
  10. Right-click on the error in the Markers view and select Quick Fix.
  11. In the Select a fix: list select Change method visibility to 'public' and click Finish.
  12. Save the Converter.java file and confirm that the error is removed.

Scenario 6: Content Assist

  1. Create a Dynamic Web Project.
  2. Import the wtp/Converter.java class into the source folder of the Dynamic Web Project.
  3. Open the Converter.java class in the Java editor.
  4. Annotate the Converter.java class with the @javax.jws.WebService annotation without using the Annotation Properties view.
  5. Add the serviceName element to the @javax.jws.WebService annotation with an empty string for a value. i.e. serviceName=""
  6. Place the cursor between the quotation marks and invoke content assist Ctrl-space.
  7. Confirm that the value ConverterService was added.
  8. Test other elements within the @javax.jws.WebService annotation and other JAX-WS annotations including @javax.xml.ws.BindingType.