Web Services Objectives After completing this lab, you will be able to: Given Create a Web Service from a Java Bean Test a Web Service using a generated test client and the Web Services Explorer The following lab artifacts can found in the RSALabs folder: Scenario Zipcode.java In this lab, you will create a Web Service based on an existing class. You will configure, deploy, and test the Web Service in the WebSphere v6.1 test environment. Task 1: Configure the Workspace In this task, you will enable Web services development capabilities in RSA. 1. From the main menu, select Window > Preferences > Workbench > Capabilities 2. From the list of capabilities, click Advanced.. check (may have to uncheck then check) Web Service Developer to automatically enable all the Web Services tools 3. Click OK
Task 2: Create the Web Application Project In this task, you will create a Web Application project that will contain the Java Bean and the Web Service that is generated. 1. Open the J2EE Perspective 2. From the File menu, select New > Enterprise Application Project 3. Name the project Zipcode and click Next 4. Click the New Module 5. Only check Create default module projects. and Web project: 6. Name the Web project: ZipcodeService and click Finish
Web Services 7. Click Finish again in the New Enterprise Application Project dialog Task 3: Import the Java Bean In this task, you will import the code needed for the Zipcode bean that will be transformed into the Web Service. 1. From the File menu, select Import 2. In the list box, select File System and click Next 3. Click Browse next to From directory: and select RSALabs and click OK 4. In the right window pane, check Zipcode.java 5. In the Into folder:, type ZipcodeService/src/com/acme/common 6. Click Finish (if imported correctly, your Project Explorer view should look like this)
Task 4: Create a Web Service from a Java Bean In this task, you will create a Web Service from a Java bean. The Web Service wizard assists you in creating a new Web Service, configuring it for deployment, and deploying the Web Service to a server. 1. In the Project Explorer, select Zipcode.java 2. From the File menu, select New > Other 3. Ensure Show All Wizards. is checked and select Web Services > Web Service 4. Click Next 5. Fill in the next screen exactly like the screenshot
Web Services 6. Click Finish (this will take a while as it is generating lots of code) 7. Popups might appear asking about Read-only files, just say Yes To All. 8. You will see the generated Web services test client in the browser.
9. Click iszipcode (java.lang.string) in the Methods pane 10. Type 98015 in the thecode: text field and click Invoke 11. You will see true in the Results pane and the TCP/IP Monitor view displays the SOAP messages sent to and from the service
Web Services Task 5: Test Using the Web Services Explorer In this task, you will test the Web Service using the Web Services Explorer. 1. In the Project Explorer view, expand JSR-109 Web Services > Services Right-click ZipcodeService and select Test with Web Services Explorer
Wait for the Web Services Explorer to display In the Navigator pane, expand and select platform:/resource/zipcodeservice/ > ZipcodeService > ZipcodeSoapBinding In the Actions pane, click iszipcode Type 98015 in the thecode text box and click Go You should now see the Web service results in the Status pane:
Web Services 2. In the Servers view, right-click Websphere Application Server v6.1, and select Stop Task 6: Close the Projects 1. Wait for the server to stop before proceeding 2. From the main menu, select File > Close All 3. Right-click on the PayApp project in the Project Explorer view and select Close Project 4. Click OK when prompted to Repair Server Configuration 5. Right-click on the Zipcode project in the Project Explorer view and select Close Project 6. Click OK when prompted to Repair Server Configuration 7. Right-click on the PayAppBusiness project in the Project Explorer view and select Close Project 8. Right-click on the PayAppPresentation project in the Project Explorer view and select Close Project 9. Right-click on the ZipcodeService project in the Project Explorer view and select Close Project 10. Right-click on the ZipcodeServiceClient project in the Project Explorer view
and select Close Project Wait until the server s status is Stopped 11. In the Servers view, right-click Websphere Application Server v6.1, and select Stop