This article is continues Part 1, where you generated and tested a J2C (or JCA) bean for a SAP resource adapter outbound scenario, using the enhanced Java EE connector tools in Rational Application Developer Version 8.0. The J2C bean artifacts have been generated in the workspace and the workspace has been launched. Part 1 also tells you what you need to have installed to work through this hands-on example.
Be sure that you've read that article before proceeding with this one. You can find it easily by clicking "More in this series."
Create a simple JSP to expose the J2C bean functionality
After the "J2C Java bean selection" view is launched under the "Java EE Resource from J2C Bean" window, the path to the generated J2C bean that you generated in Part 1 is automatically entered in the "J2C bean implementation" field (see Figure 1). Now you need to create a simple JavaServer Page (JSP) to expose the functionality provided by the generated J2C bean.
- In that "J2C Java bean selection" window, click Next.
Figure 1. Select the J2C bean to generate deployment artifacts
- On the Deployment Information page (Figure 2), there are four deployment options: EJB, Faces Web Page, Simple JSP and Web Service. The default deployment method is Simple JSP.
- Check the box labeled Configure Resource Adapter Deployment so you can configure the way that the resource adapter deployment will show, in step 5.
- Click Next.
Figure 2. Simple JSP selected by default
- To generate a Simple JSP, you need to create a dynamic web project to hold it, so click the New button next to the web project to generate that project. For Target Runtime, use WebSphere Application Server V7.0.
The name of the web project will automatically show in the "Web project" name field.
- For the "JSP folder" name, enter
sample(see Figure 3), and click Next.
Figure 3. Generate the simple JSP
- When the Resource Adapter Deployment page appears, click Finish to generate the deployment artifacts.
If you do not select the "Configure Resource Adapter Deployment" check box in step 2, this page won't show.
The default SAP resource adapter deployment is "Deploy as Stand Alone," which means that the resource adapter will be installed on WebSphere Application Server. For this example, it will be installed on Version 7.0. After it is installed on that server, the applications that need the SAP resource adapter to connect SAP server can share the same resource adapter.
However, if you select "Deploy within EAR," the resource adapter will be packaged within the EAR file and will not be visible or used by other applications.
Figure 4. Select the default resource adapter deployment option
- Inspect the content of the Java project and the web project. Figure 5 shows the structure of the artifacts generated both for the Java project, SAPBAPISample, and the web project TestWeb.
The J2C bean is generated in the Java project with schema files, and simple JSPs are generated in the web project.
Figure 5. Artifacts generated for both the web and Java projects
Test the simple JSP on WebSphere Application Server
- First, you must deploy an EAR file that contains your web project to the WebSphere Application Server, Version 7.0, as shown in the Add and Remove window in Figure 6.
Figure 6. Add the EAR file to the WebSphere server
To deploy the EAR file to the WebSphere, you need to open the Server view, right-click the WebSphere 7.0 server instance, and select Add and Remove.
- Now, right-click TestClient.jsp, and then select Run As > Run on Server (see Figure 7).
- Run TestClient.jsp on the WebSphere Application Server.
Figure 7. Test the createSapBapiDemoWrapper method
- In the left pane of the Web Services Test Client tab (TestClient.jsp file), under Methods, click createSapBapiDemoWrapper in. Input data is shown in the Inputs.jsp file which is shown in Figure 8.
Figure 8. Test the "createSapBapiDemoWrapper" method
- Enter this input data in the Inputs.jsp file:
- Under sapPiPersonaldata, enter those values:
- city: Burlingame
- lastName: Johnson
- firstName: Tom
- countryKey: US
- currencyKey: USD
- cityPostalCode: 94010
- dateOfBirth: May 03, 1965
- languageKey: EN
- regionStateProvinceCounty: CA
- Under sapPiCopyreference, enter the following values:
- distributionChannel: 01
- division: 01
- salesOrganization: 0001
- referenceCustomer: 01
- Under sapPiPersonaldata, enter those values:
- Then click Invoke from Result.jsp to create a new customer number.
Figure 9. The Result.jsp display
As Figure 10 shows, similar log messages are displayed from the WebSphere Application Server console view.
Figure 10. WebSphere Application server console view log
This article showed how easy a J2C bean can be created with the J2C tools provided in Rational Application Developer V8.0. With just a few steps, you can build an application that can access the functions of the SAP backend system. That functionality can be quickly exposed to other applications and business processes through the generated web page.
- Find out more about Rational Application Developer:
- Browse the Rational Application Developer for WebSphere Software page on developerWorks for links to technical articles and many related resources.
- Explore the Information Center.
- Visit the Rational software area on developerWorks for technical resources and best practices for Rational Software Delivery Platform products.
- Stay current with developerWorks technical events and webcasts focused on a variety of IBM products and IT industry topics.
- Attend a free developerWorks Live! briefing to get up-to-speed quickly on IBM products and tools, as well as IT industry trends.
- Watch developerWorks on-demand demos, ranging from product installation and setup demos for beginners to advanced functionality for experienced developers.
- Improve your skills. Check the Rational training and certification catalog, which includes many types of courses on a wide range of topics. You can take some of them anywhere, any time, and many of the "Getting Started" ones are free.
Get products and technologies
- Try Rational Application Developer for WebSphere Software, free.
- Evaluate IBM software in the way that suits you best: Download it for a trial, try it online, use it in a cloud environment, or spend a few hours in the SOA Sandbox learning how to implement service-oriented architecture efficiently.
- Check Rational Application Developer wiki to keep up with news and to contribute.
- Join the Development Tools forum to ask questions and participate in discussions.
- Share your knowledge and help others who use Rational software by writing a developerWorks article. You'll get worldwide exposure, RSS syndication, a byline and a bio, and the benefit of professional editing and production on the developerWorks Rational website. Find out what makes a good developerWorks article and how to proceed.
- Follow Rational software on Facebook and Twitter (@ibmrational), and add your comments and requests.
- Ask and answer questions and increase your expertise when you get involved in the Rational forums, cafés, and wikis.
- Connect with others who share your interests by joining the developerWorks community and responding to the developer-driven blogs.