MyBank Application using JAXB and SCA

 

Overview

This sample demonstrates the use of a top down approach to create an SCA application using JAXB. 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.

Part 1: Create the 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.

1.          Open a command window and change to the <WAS_HOME>\samples\SCA\MyBank\accountservice directory.

2.          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

3.          Verify that the build completes without error.

4.          The output of the build command can be found under the <WAS_HOME>\samples\SCA\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

5.          Verify that the following Java classes have been generated in the <WAS_HOME>\samples\SCA\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

6.          Verify that the mybank-accountservice.jar BLA module has been generated in the <WAS_HOME>\samples\SCA\MyBank\accountservice\target\ directory.

Part 2: Inspect and build the 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:

1.          Open a command window and change to the <WAS_HOME>\MyBank\accountclient directory.

2.          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

3.          Verify that the build completes without error. 

4.          The output of the build command can be found under the <WAS_HOME>\samples\SCA\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

 

5.          Verify that the following Java classes have been generated in the <WAS_HOME>\samples\SCA\MyBank\accountclient\target\generated\java\com\mybank\account directory.

AccountReport.java

AccountService.java

AccountService_Service.java

AccountSummary.java

GetAccountReport.java

GetAccountReportResponse.java

ObjectFactory.java

6.          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.

Part 3: Install the MyBank Application

This section describes how to install both the MyBank Account Service and My Bank Client applications.

1.        Start the WebSphere Application Server if it is not already started.

                __ a. 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

                __ b. Issue the startServer command

startServer server1

2.      Create the MyBank data source using the Administrative console.

__ a. 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

__ b. Enter a username and password if required and press Log in.

3.      You are using a Derby database for this application.  Create a Derby JDBC provider if there is not one already defined.

__ a. From the left navigation panel of the Administrative console, expand Resources > JDBC and click on JDBC Providers.

__ b. On the JDBC Provider page select Node=<NODE_NAME>, Server=server1 from the scope drop down list before creating a new JDBC provider.

__ c. Still on the JDBC Provider page, click New to create a new JDBC Provider.

__ d. Select Derby from the Database type drop down list.

__ e. Select Derby JDBC Provider from the Provider type drop down list.

__ f. Select Connection pool data source from the Implementation type drop down list

__ g. Accept the default name of Derby JDBC Provider.

__ h. Click Next and on the Summary page click Finish.

__ i. Click the Save link at the top of the JDBC Provider page to save your changes.

4.      Create a new data source for use in the MyBank application.

__ a. From the left navigation panel of the Administrative console, expand Resources > JDBC and click on Data sources.

__ b. On the Data Sources page, select Node=<NODE_NAME>, Server=server1 from the scope drop down list.

__ c. Still on the Data Sources page, click New to create a new Data Source.

__ d. Enter MyBankDB for the Data source name.

__ e. Enter mybank for the JNDI name.

__ f. Click Next.

__ g. For the JDBC Provider, choose select an existing one and select the Derby JDBC Provider from the drop down list.

__ h. Click Next.

__ i. On the database specific properties page enter the path to the MyBankDB directory located in %WAS_HOME%\samples\SCA\MyBank (for example, C:/WebSphere/AppServer/samples/SCA/MyBank/MyBankDB) for the Database name. Uncheck the Use this data source in container managed persistence (CMP) checkbox and click Next

__ j. On the setup security aliases page, take default value and click Next

__ k. Click Finish on the summary panel.

__ l. Click the Save link at the top of the Data sources page to save your changes.

__ m. 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

__ n. Click the Logout link at the top of the administrative console.

5.      Use the wsadmin BLA commands to install the MyBank Account Service application packaged in the mybank-accountservice.jar file.

__ a. 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

__ b. Once wsadmin starts, issue the following command

$AdminTask createEmptyBLA {-name MyBankAccountService}

__ c. When this completes you should see the blaID output in the command window:

  WebSphere:blaname=MyBankAccountService

__ d. Once bla is created, issue the following command to copy the JAR archive

$AdminTask importAsset {-source C:/WebSphere/AppServer/samples/SCA/MyBank/accountservice/target/mybank-accountservice.jar -storageType FULL}

__ e. When this completes you should see the asset output in the command window:

            WebSphere:assetname=mybank-accountservice.jar

__ f. Once JAR is copied, issue the following command

$AdminTask addCompUnit {-blaID MyBankAccountService -cuSourceID mybank-accountservice.jar}

__ g. When this completes you should see the config unit ID output in the command window:

WebSphere:cuname=MyBank

__ h. Issue the following command to save your changes

$AdminConfig save

6.      Use the listBLAs command to verify the MyBankAccountService exists

$AdminTask listBLAs

7.      Start the application

__ a. From the wsadmin shell issue the following command to start the application

$AdminTask startBLA {-blaID MyBankAccountService}

8.      Type exit to exit wsadmin command shell

9.      Log into the Administrative Console

__ a. 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

__ b. Enter a username and password if required and press Log in.

10.    Install the My Bank client application from the Administrative Console

__ a. From the left navigation panel of the Administrative console, expand Applications --> New Application. Select New Enterprise Application.

__ b. 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 C:/WebSphere/AppServer/samples/SCA/MyBank/accountclient/target/ directory.

__ c. 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.

__ d. Select the Next button at the bottom of the panel

__ e. 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.

__ f. Verify in the admin console that the MyBank client has installed successfully.

__ g. 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.

__ h. Verify that the MyBank application has started.  The application status for the mybank-client _war should show a green arrow.  

__ i. Click the Logout link at the top of the Administrative console.

 

1.      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.

2.        Verify that you see the AccountService.wsdl definition in your browser.

3.      Open a browser window and enter the following URL http://localhost:9080/mybankClient/MyBankWeb.jsp.

4.      Verify that you see the MyBank application.

5.      Enter 100 and press Submit.

6.      Verify that you see example data returned