corner imagecorner image
IDEPlatformPluginsDocs & SupportCommunityPartners

End-to-End Binary SOAP Attachment 4: Testing the Web Service

Download the sample

When you deploy a web service to an application container, the IDE lets you test the web service to see if it functions as you expect. The Tester application, provided by GlassFish, is available from the IDE for this purpose.

In this tutorial, you begin by creating an enterprise application. After you add the EJB module and the web service to the enterprise application, you deploy them together, as one unit, by deploying the enterprise application.

Lessons In This Tutorial

Content on this page applies to NetBeans IDE 6.5
  1. Overview
  2. Creating the EJB Module
  3. Creating the Web Service
  4. => Testing the Web Service
  5. Modifying the Schema and WSDL Files to Pass Binary Data
  6. Creating the Swing Client

Testing the Web Service

In the following procedure, you create a web application containing both the EJB module and the web service you created in earlier tutorials. After you deploy the application, you can use it to test the web service.

To test the web service:

  1. Choose File > New Project (Ctrl-Shift-N). The New Project wizard appears. Select Enterprise Application from the Enterprise category

    Click Next. The Name and Location page opens.

  2. In the Project Name field, type FlowerApplication. Select the location you want for this project—use the same location for the other projects you create for the end-to-end application. Keep the default settings for the other options and click Next. The Server and Settings page opens.

  3. Select the application server and Java EE version. This must be the same for all projects in the end-to-end application. Make sure to deselect the Create EJB Module checkbox and the Create Web Application Module checkbox, because you do not want to create new modules. You now see the following in the wizard.
    New enterprise application wizard

    Click Finish. A new enterprise application is added to the IDE. Now we need to add our two modules to the application.

  4. Right-click the FlowerApplication Java EE Modules node and choose Add Java EE Module, as shown below.
    Java EE Modules node context menu showing Add Module option
  5. The Add Java EE module dialog opens. Choose both the FlowerAlbum and FlowerService modules and click OK. You should now see that the two modules are added to the application, as shown below.
    Projects view showing newly added Java EE modules
  6. Right-click the FlowerApplication node and choose Properties from the context menu. Choose Run from the categories. Type /FlowerService?Tester in the Relative URL field, as shown here, and click OK.
    Project properties dialog showing Run category with relative URL modified
  7. Right-click the FlowerApplication node. From the context menu, select Run. If the server is not running, the IDE will start it. Then it will deploy the application, containing our two modules, to the server. Next, because of the settings specified in the previous dialog, the browser will open and display the Tester application, shown below.
    Flower Service web service tester in browser

    Once you see the Tester application, open the Services window in the IDE, expand the Servers node, and notice that the IDE added new nodes for the deployed application and its modules, as shown here.
    Services view showing newly deployed applications and modules

    You now know for sure that the application has been successfully deployed.

  8. Click WSDL File in the Tester application and notice that the browser now shows the WSDL file.
    Flower Service WSDL in browser
  9. Above, the browser shows, among other things, the location of the schema. Type or paste the URL of the schema in the browser and the schema file appears.
    Flower Service Schema in browser
  10. Return to the Tester window. Type the name of one of the images, such as "rose", in the Tester application.
  11. Click the getFlower button and the IDE shows you information about the invocation in the browser.
    Results of testing getFlower, including SOAP request and response

When you look at the "Method Returned" above, you see that it is garbled. You want to see an image, not a series of symbols. However, since java.awt.Image is not a valid schema type, you need to manually configure the schema file to return binary image/jpeg data. You will do this in the next tutorial.

Next step:

Modifying the Schema and WSDL Files to Pass Binary Data

To send comments and suggestions, get support, and keep informed on the latest developments on the NetBeans IDE Java EE development features, join the mailing list.