My Bank Sample
Table of Contents
Overview
This sample demonstrates the use of a top down approach to create an SCA application. An AccountService wsdl is used to generate the JAXB classes that provide a data binding between XML and Java. A reference on the client side war is then used to wire to the Account Service over the web service binding. An alternate version of the AccountService has been provided which illustrates implementing the service using impl.osgiapp and SDO databinding.
Prerequisites
Limitations
There are no noteable design limitations specific to this sample.
Build
MyBank Account Service Application
The key artifacts that make up the MyBank Account Service application are:
- default.composite
- AccountService.java (generated using wsimport from AccountService.wsdl)
- AccountServiceImpl.java
- AccountService.wsdl
- JAXB classes providing a data binding between XML and Java (generated using the wsimport)
Compile the MyBank Account Service application and verify that everything has been added to the build.xml file properly.
- Open a command window and change to the <SCA_SAMPLE_HOME>\MyBank\accountservice directory.
-
Issue the following command to build the application:
<WAS_HOME>\profiles\<PROFILE_NAME>\bin\ws_ant
Example command:
C:\WebSphere\AppServer\profiles\AppSrv01\bin\ws_ant
- Verify that the build completes without error.
-
The output of the build command can be found under the <SCA_SAMPLE_HOME>\MyBank\accountservice\target directory. Verify that the following artifacts have been generated by the build:
<WAS_HOME>\MyBank\accountservice\target\classes (Location of .class files)
<WAS_HOME>\MyBank\accountservice\target\generated\java (Location of generated Java source)
-
Verify that the following Java classes have been generated in the <SCA_SAMPLE_HOME>\MyBank\accountservice\target\generated\java\com\mybank\account directory.
- AccountReport.java
- AccountService.java
- AccountService_Service.java
- AccountSummary.java
- GetAccountReport.java
- GetAccountReportResponse.java
- ObjectFactory.java
- package-info.java
- Verify that the mybank-accountservice.jar BLA module has been generated in the <SCA_SAMPLE_HOME>\MyBank\accountservice\target\ directory.
MyBank Client Application
The key artifacts that make up the MyBank Client application are:
- default.composite
- AccountService.java (generated using wsimport from AccountService.wsdl)
- AccountSummaryService.java
- AccountSummaryServiceImpl.java
- AccountService.wsdl
- MyBankWeb.jsp
- JAXB classes providing a data binding between XML and Java (generated using wsimport)
To build and package the MyBank Account Service application:
- Open a command window and change to the <WAS_HOME>\MyBank\accountclient directory.
-
Issue the following command to build the application:
<WAS_HOME>\profiles\<PROFILE_NAME>\bin\ws_ant
Example command:
C:\WebSphere\AppServer\profiles\AppSrv01\bin\ws_ant
- Verify that the build completes without error.
-
The output of the build command can be found under the <SCA_SAMPLE_HOME>\MyBank\accountclient\target directory. Verify that the following artifacts have been generated by the build:
<WAS_HOME>\MyBank\accountclient\target\classes (Location of .class files)
<WAS_HOME>\MyBank\accountclient\target\generated\java (Location of generated Java source)
-
Verify that the following Java classes have been generated in the <SCA_SAMPLE_HOME>\MyBank\accountclient\target\generated\java\com\mybank\account directory.
- AccountReport.java
- AccountService.java
- AccountService_Service.java
- AccountSummary.java
- GetAccountReport.java
- GetAccountReportResponse.java
- ObjectFactory.java
- Verify that the output WAR file (mybank-client.war) is found under the <WAS_HOME>\MyBank\accountclient\target\ directory. You will use this WAR file in Part 3 to install the MyBank Client application.
Install
Automated install: To quickly and easily install this sample and bypass the manual steps following, you can use the automated install. Run the following command from the MyBank sample directory:
<WAS_HOME>\profiles\<PROFILE_NAME>\bin\ws_ant install
<WAS_HOME>\profiles\<PROFILE_NAME>\bin\ws_ant start
NOTE: If the default port number for SOAP is not 8880 for your application server profile, please update the SOAP port number value in <SCA_SAMPLE_HOME>\common\manage-app.xml to match your profile.
Manual install
This section describes how to install both the MyBank Account Service and My Bank Client applications.
- Start the WebSphere Application Server if it is not already started.
-
Open a command window and issue the following command:
cd <WAS_HOME>\profiles\<PROFILE_NAME>\bin
Example command:
cd C:\WebSphere\AppServer\profiles\AppSrv01\bin
-
Issue the startServer command:
startServer server1
- Create the MyBank data source using the Administrative console.
-
Log into the Administrative Console by navigating to http://localhost:9060/ibm/console in a Web browser.
NOTE: If the default Admin port is not 9060 for your application server profile, the URL above should include the port number for your installation.
- Enter a username and password if required and press Log in.
- You are using a Derby database for this application. Create a Derby JDBC provider if there is not one already defined.
- From the left navigation panel of the Administrative console, expand Resources > JDBC and click on JDBC Providers.
- On the JDBC Provider page select Node=<NODE_NAME>, Server=server1 from the scope drop down list before creating a new JDBC provider.
- Still on the JDBC Provider page, click New to create a new JDBC Provider.
- Select Derby from the Database type drop down list.
- Select Derby JDBC Provider from the Provider type drop down list.
- Select Connection pool data source from the Implementation type drop down list
- Accept the default name of Derby JDBC Provider.
- Click Next and on the Summary page click Finish.
- Click the Save link at the top of the JDBC Provider page to save your changes.
- Create a new data source for use in the MyBank application.
- From the left navigation panel of the Administrative console, expand Resources > JDBC and click on Data sources.
- On the Data Sources page, select Node=<NODE_NAME>, Server=server1 from the scope drop down list.
- Still on the Data Sources page, click New to create a new Data Source.
- Enter MyBankDB for the Data source name.
- Enter mybank for the JNDI name.
- Click Next.
- For the JDBC Provider, choose select an existing one and select the Derby JDBC Provider from the drop down list.
- Click Next.
- On the database specific properties page enter the path to the MyBankDB directory located in <SCA_SAMPLE_HOME>\MyBank. for the Database name. Uncheck the Use this data source in container managed persistence (CMP) checkbox and click Next
- On the setup security aliases page, take default value and click Next
- Click Finish on the summary panel.
- Click the Save link at the top of the Data sources page to save your changes.
- Once the changes are saved, check the box next to MyBankDB in the list of Data sources, and click the Test Connection button. Verify that you see a message that the test was successful
- Click the Logout link at the top of the administrative console.
- Use the wsadmin BLA commands to install the MyBank Account Service application packaged in the mybank-accountservice.jar file.
-
Open a command window and issue the following command
<WAS_HOME>\profiles\<PROFILE_NAME>\bin\wsadmin
Example command:
C:\WebSphere\AppServer\profiles\AppSrv01\bin\wsadmin
-
Once wsadmin starts, issue the following command:
$AdminTask createEmptyBLA {-name MyBankAccountService}
-
When this completes you should see the blaID output in the command window:
WebSphere:blaname=MyBankAccountService
-
Once bla is created, issue the following command to copy the JAR archive
$AdminTask importAsset {-source <SCA_SAMPLE_HOME>/MyBank/accountservice/target/mybank-accountservice.jar -storageType FULL}
-
When this completes you should see the asset output in the command window:
WebSphere:assetname=mybank-accountservice.jar
-
Once JAR is copied, issue the following command
$AdminTask addCompUnit {-blaID MyBankAccountService -cuSourceID mybank-accountservice.jar}
-
When this completes you should see the config unit ID output in the command window:
WebSphere:cuname=MyBank
-
Issue the following command to save your changes
$AdminConfig save
-
Use the listBLAs command to verify the MyBankAccountService exists
$AdminTask listBLAs
- Start the application
-
From the wsadmin shell issue the following command to start the application:
$AdminTask startBLA {-blaID MyBankAccountService}
- Type
exit
to exit wsadmin command shell
- Log into the Administrative Console
-
In a web browser, navigate to http://localhost:9060/ibm/console.
NOTE: If the default Admin port is not 9060 for your application server profile, the URL above should include the port number for your installation.
- Enter a username and password if required and press Log in.
- Install the My Bank client application from the Administrative Console
- From the left navigation panel of the Administrative console, expand Applications --> New Application. Select New Enterprise Application.
- On the install panel, specify the Local file system option and enter the Full path or use the browse button to select the mybank-client.war file located in the <SCA_SAMPLE_HOME>/MyBank/accountclient/target/ directory.
- Since the sample application is a WAR file, you need to specify the context root of the Web module in the WAR file. Specify the Context root as mybankClient.
- Select the Next button at the bottom of the panel
- For the remaining install panels, select the defaults by clicking Next until you reach the final panel. Click Finish to complete the installation of the sample application.
- Verify in the admin console that the MyBank client has installed successfully.
- Once the application is installed, save the changes by clicking on the Save link. The application will appear in the list of applications and its initial status will be stopped (status of Red). Check the box next to mybank-client _war and press Start.
- Verify that the MyBank application has started. The application status for the mybank-client _war should show a green arrow.
- Click the Logout link at the top of the Administrative console.
Running
-
Open a browser window and enter the following URL: http://localhost:9080/AccountServiceComponent/AccountService/?wsdl.
NOTE: If the default HTTP transport port is not 9080 for your application server profile, the URL above should include the port number for your installation.
- Verify that you see the AccountService.wsdl definition in your browser.
- Open a browser window and enter the following URL http://localhost:9080/mybankClient/MyBankWeb.jsp.
- Verify that you see the MyBank application.
- Enter 100 and press Submit.
- Verify that you see example data returned.
Uninstall
Automated uninstall: To quickly and easily uninstall this sample and bypass the manual steps following, you can use the automated uninstall. Run the following command from the My Bank sample directory:
<WAS_HOME>\profiles\<PROFILE_NAME>\bin\ws_ant uninstall
Manual uninstall
- From the left navigation panel of the Administrative console, expand Applications then Application Types and select Business-level Applications. You should see one My Bank related BLA on this page, MyBankAccountService. Click on MyBankAccountService. Under Deployed assets check all the non Shared Library assets and click delete. These assets are usually marked as "asset" under the Type column.
- After the non shared library assets are removed, select all the shared library assets that are left under Deployed assets and delete them. Once all the assets are removed, click on the Save link at the top of the screen.
- Expand Applications then Application Types and select Business-level Applications. Select the MyBankAccountService and click on delete and then click the Save link at the top of the screen.
- Next you will need to uninstall the My Bank client war. Expand Applications then Application Types and select WebSphere Enterprise Applications. Select mybank-client_war and click on Uninstall. After the client application has been removed click on the Save link at the top of the screen.
User's Guide
When you run the sample you should see a page that looks like this:
Use account number 100 (the default), and press submit. Example account information will be displayed from the database and should look something like this: