Async HelloWorld Web Service Sample

Table of Contents:

Async HelloWorld Web Service Sample

Part 1: Overview

Part 2: Build

Part 3: Install

Part 4: Running

Part 5: Uninstall

Part 1: Overview


This sample has three installables, the client helloworld-ws-client-asynch.war and two services the helloworld-ws-asynchclient.jar and the helloworld-ws-asynch.jar.  The client using a JSP obtains an SCA composite context and invokes the HelloWorldRemotable service over a SCA default binding.   This component then invokes the AsynchTranslatorService service over a Web Services binding.   Once the AsynchTranslatorService is invoked, it does a callback back to its client.  The original client JSP waits for 5 seconds for the callback to complete and then calls the HelloWorldRemotable service again to get and display the callback result.  If the callback fails the client displays a failure message.  The client JSP programmatically creates a reference to the HelloWorldRemotable  service which is packaged in the helloworld-ws-asynchclient.jar.  This HelloWorldRemotable service has a reference to the AsynchTranslatorService service  which is packaged in the helloworld-ws-asynch.jar.  An SCA service exposed over the Web Services binding is always packaged as a jar.  An SCA reference can be packaged in a jar or a war. An SCA reference that implements a callback over the Web Services binding must be packaged in a jar. Callback references using the Web Services binding are exported as a service.


This sample is based upon the helloworldws-async and helloworldwsclient-async samples contained within Tuscany.

 

Diagram of Async Hello World

Part 2: Build

Compile and build the installable artifacts using the provided ANT build script.

a) Open a command window and change to the {WAS_HOME}\samples\SCA\helloworld-ws-asynch directory.

b) Issue the following command to build the artifacts: {WAS_HOME}\profiles\{PROFILE_NAME}\bin\ws_ant

Example command: C:\WebSphere\AppServer\profiles\AppSrv01\bin\ws_ant

c) Verify that the build completes without error and the following atrifacts have been created in {WAS_HOME}\samples\SCA\helloworld-ws-asynch\target

helloworld-ws-client-asynch.war
helloworld-ws-asynchclient.jar
helloworld-ws-asynch.jar

Part 3: Install

Start WebSphere Application Server.

Install the Async Hello World client application from the Administrative Console

From the left navigation panel of the Administrative console, expand Applications and select New Application.  Then 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 helloworld-ws-client-asynch.war file located in the <WAS_HOME>/samples/SCA/helloworld-ws-asynch/target/ directory. Click Next, and then Continue until you reach the “Map context roots for Web modules” page.

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

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 application 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). 

Expand Applications then Application Types and select WebSphere enterprise applications. Check the box next to helloworld-ws-client-asynch_war and press Start.

Verify that the application has started.  The application status for the helloworld-ws-client-asynch_war should show a green arrow.  



Install and start the helloworld-ws-asynchclient.jar through the command line using the wsadmin BLA commands.  First 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 commands:

$AdminTask createEmptyBLA {-name myhelloWorldClient}

$AdminTask importAsset {-source WAS_HOME\samples\SCA\helloworld-ws-asynch\target\helloworld-ws-asynchclient.jar –storageType FULL}

$AdminTask addCompUnit {-blaID myhelloWorldClient –cuSourceID helloworld-ws-asynchclient.jar}

$AdminConfig save

$AdminTask startBLA {-blaID myhelloWorldClient}

You can replace the “myhelloWorldClient” with any name of your choice.


Install and start the helloworld-ws-asynch.jar through the command line using the wsadmin BLA commands.  The required commands are:

 

$AdminTask createEmptyBLA {-name myhelloWorld}

$AdminTask importAsset {-source WAS_HOME\samples\SCA\helloworld-ws-asynch\target\helloworld-ws-asynch.jar –storageType FULL}

$AdminTask addCompUnit {-blaID myhelloWorld –cuSourceID helloworld-ws-asynch.jar}

$AdminConfig save

$AdminTask startBLA {-blaID myhelloWorld}

You can replace the “myhelloWorld” with any name of your choice.

 

Note: You can optionally choose to install these through the administration console.

 

Part 4: Running

Using a web browser open http://host:port/contextRoot
for example: http://localhost:9080/helloWorldAsync

 

Specific to your environment:

  • host: Hostname where the server is located
  • port: Port for WebSphere application server host
  • contextRoot: Context root which you installed helloworld-ws-client-asynch.war

 

Results: The browser will display a hello world message and then confirm that a callback was received.

 

Part 5: Uninstall

5.1 To uninstall the SCA service (jar's)

 

Uninstall the helloworld-ws-asynchclient.jar and helloworld-ws-asynch.jar files through the command line using the wsadmin BLA commands.  First 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 commands:

$AdminTask stopBLA {-blaID myhelloWorldClient}

 $AdminTask deleteCompUnit {-blaID myhelloWorldClient -cuID helloworldwsclient}

 $AdminTask deleteAsset {-assetID helloworld-ws-asynchclient.jar}

 $AdminTask deleteBLA {-blaID myhelloWorldClient}

 

$AdminTask stopBLA {-blaID myhelloWorld}

 $AdminTask deleteCompUnit {-blaID myhelloWorld -cuID helloworldws}

 $AdminTask deleteAsset {-assetID helloworld-ws-asynch.jar}

 $AdminTask deleteBLA {-blaID myhelloWorld}

 

 $AdminConfig save

 

 

Note: you can optionally choose to uninstall these through the administration console.

 

5.2 To uninstall the SCA client (war)

 

From the left navigation panel of the Administrative console, expand Applications then Application Types and select WebSphere enterprise applications. Select helloworld-ws-client-asynch_war and click on Uninstall. After the client application has been removed click on the Save link at the top of the screen.