Java & J2EE Page 8 - Using RPC-Style Web Services with J2EE |
You will package up the Web Service in a WAR file, so choose File, New, Web Component to create a new one. Click Next to skip the introduction screen and move onto the WAR file creation screen. You will be creating a New Stand-Alone WAR Module so ensure that this option is selected. Next, under WAR Naming, browse to a location in which you wish to save your WAR file and provide "wsgreeting" as the File Name. Now you can populate your WAR with the files you saw earlier. Under the Contents section, click the Edit button to display the Edit Contents of wsgreeting screen. Browse to find the class files (Greeting.class and GreetingImplementation.class), the WSDL file (GreetingService.wsdl – created in folder build/generated), and the mapping file (mapping.xml – created in folder build/generated). Add each of these files to the contents as shown in Figure 20.6 and click OK.
Figure 20.6 Your WAR file settings should look similar to those in Figure 20.7.
Figure 20.7 Click Next to move on to the Choose Component Type screen and select Web Services Endpoint. Click Next to move onto the Choose Service screen. Under the Service Definition, the WSDL File drop-down list should offer you the GreetingService.wsdl file and the Mapping File drop-down list should offer you the mapping.xml file. Select these two files so that your screen looks like that in Figure 20.8. You will see that the service name has been picked up from the WSDL file.
Figure 20.8 Now click Next to move onto the Component General Properties window. Select wsexamples.GreetingImplementation as your Service Endpoint Implementation (this will be offered from the drop-down list). Again, the fields will be populated based on the information in the file. Click Next to move on to the Web Service Endpoint screen. Select wsexamples.Greeting as your Service Endpoint Interface. In the WSDL Port section, set the Namespace to be urn:J2EE21Examples and ensure that the Local Part becomes GreetingPort as shown in Figure 20.9.
Figure 20.9 That completes the initial configuration, so click Next followed by Finish. You should be presented with a deploytool screen that looks like Figure 20.10.
Figure 20.10 Configuring the WAR and Component There are three final bits of Sun-specific configuration that are needed to complete the Web Service WAR. First, select the General tab of the wsgreeting WAR file (as shown in Figure 20.10). Set the Context Root field to /wsgreeting. Now select the GreetingImplementation component in the left-hand pane. Select the Aliases tab and Add an alias of /GreetingService as shown in Figure 20.11. Finally, select the Endpoint tab and change the Endpoint Address at the bottom of the tab to be GreetingService. You should now save your WAR file and you are ready to deploy your service. During this process, deploytool has generated several new files for you:
Figure 20.11
blog comments powered by Disqus |
|
|
|
|
|
|
|