Author: Paul Robinson
Level: Intermediate
Technologies: WS-BA, JAX-WS
Summary: The wsba-participant-completion-simple
quickstart deploys a WS-BA (WS Business Activity) enabled JAX-WS Web service WAR (ParticipantCompletion Protocol).
Target Product: WildFly
Source: https://github.com/wildfly/quickstart/
The wsba-participant-completion-simple
quickstart demonstrates the deployment of a WS-BA (WS Business Activity) enabled JAX-WS Web service bundled in a WAR archive (ParticipantCompletion Protocol) for deployment to WildFly Application Server.
The Web service exposes a simple 'set' collection as a service. The Service allows items to be added to the set within a Business Activity.
The example demonstrates the basics of implementing a WS-BA enabled Web service. It is beyond the scope of this quickstart to demonstrate more advanced features. In particular
For a more complete example, please see the XTS demonstrator application that ships with the Narayana project: http://narayana.io.
It is also assumed tht you have an understanding of WS-BusinessActivity. For more details, read the XTS documentation that ships with the Narayana project: http://narayana.io/docs/product
The application consists of a single JAX-WS web service that is deployed within a WAR archive. It is tested with a JBoss Arquillian enabled JUnit test.
When running the org.jboss.as.quickstarts.wsba.participantcompletion.simple.ClientTest#testSuccess() method, the following steps occur:
JaxWSHeaderContextProcessor
in the WS Client handler chain inserts the BA context into the outgoing SOAP message.JaxWSHeaderContextProcessor
in its handler chain inspects the BA context and associates the request with this BA.ParticipantCompletion
protocol.There are additional tests that show:
The application this project produces is designed to be run on WildFly Application Server 11 or later.
All you need to build this project is Java 8.0 (Java SDK 1.8) or later and Maven 3.3.1 or later. See Configure Maven for WildFly 11 to make sure you are configured correctly for testing the quickstarts.
Next you need to start WildFly with the XTS subsystem enabled. This is enabled through the optional server configuration standalone-xts.xml. To do this, run the following commands from the top-level directory of WildFly:
For Linux: ./bin/standalone.sh --server-config=../../docs/examples/configs/standalone-xts.xml | egrep "started|stdout"
For Windows: \bin\standalone.bat --server-config=..\..\docs\examples\configs\standalone-xts.xml | egrep "started|stdout"
Note, the pipe to egrep (| egrep "started|stdout") is useful to just show when the server has started and the output from these tests. For normal operation, this pipe can be removed.
This quickstart provides Arquillian tests. By default, these tests are configured to be skipped as Arquillian tests require the use of a container.
mvn clean verify -Parq-remote
You should see the following result.
Results :
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
Note: You see the following warning when you run the Arquillian tests in remote mode.
WARNING: Configuration contain properties not supported by the backing object org.jboss.as.arquillian.container.remote.RemoteContainerConfiguration
Unused property entries: {serverConfig=../../docs/examples/configs/standalone-xts.xml}
Supported property names: [managementAddress, password, managementPort, managementProtocol, username]
This is because, in remote mode, you are responsible for starting the server with the XTS subsystem enabled. When you run the Arquillian tests in managed mode, the container uses the serverConfig
property defined in the arquillian.xml
file to start the server with the XTS subsystem enabled.
You can also let Arquillian manage the WildFly server by using the arq-managed
profile. For more information about how to run the Arquillian tests, see Run the Arquillian Tests.
The following messages should appear in the server log. Note there may be other log messages interlaced between these. The messages trace the steps taken by the tests.
Test success:
INFO [stdout] (management-handler-threads - 6) Starting 'testSuccess'. This test invokes a WS within a BA. The BA is later closed, which causes the WS call to complete successfully.
INFO [stdout] (management-handler-threads - 6) [CLIENT] Creating a new Business Activity
INFO [stdout] (management-handler-threads - 6) [CLIENT] Beginning Business Activity (All calls to Web services that support WS-BA wil be included in this activity)
INFO [stdout] (management-handler-threads - 6) [CLIENT] invoking addValueToSet(1) on WS
INFO [stdout] (http-localhost-127.0.0.1-8080-1) [SERVICE] invoked addValueToSet('1')
INFO [stdout] (http-localhost-127.0.0.1-8080-1) [SERVICE] Enlisting a participant into the BA
INFO [stdout] (http-localhost-127.0.0.1-8080-1) [SERVICE] Invoking the back-end business logic
INFO [stdout] (http-localhost-127.0.0.1-8080-1) [SERVICE] Prepare the backend resource and if successful notify the coordinator that we have completed our work
INFO [stdout] (http-localhost-127.0.0.1-8080-1) [SERVICE] Prepare successful, notifying coordinator of completion
INFO [stdout] (http-localhost-127.0.0.1-8080-1) [SERVICE] Participant.confirmCompleted('true') (This tells the participant that compensation information has been logged and that it is safe to commit any changes.)
INFO [stdout] (http-localhost-127.0.0.1-8080-1) [SERVICE] Commit the backend resource (e.g. commit any changes to databases so that they are visible to others)
INFO [stdout] (management-handler-threads - 6) [CLIENT] Closing Business Activity (This will cause the BA to complete successfully)
INFO [stdout] (TaskWorker-2) [SERVICE] Participant.close (The participant knows that this BA is now finished and can throw away any temporary state)
Test cancel:
INFO [stdout] (management-handler-threads - 5) Starting 'testCancel'. This test invokes a WS within a BA. The BA is later cancelled, which causes these WS call to be compensated.
INFO [stdout] (management-handler-threads - 5) [CLIENT] Creating a new Business Activity
INFO [stdout] (management-handler-threads - 5) [CLIENT] Beginning Business Activity (All calls to Web services that support WS-BA will be included in this activity)
INFO [stdout] (management-handler-threads - 5) [CLIENT] invoking addValueToSet(1) on WS
INFO [stdout] (http-localhost-127.0.0.1-8080-1) [SERVICE] invoked addValueToSet('1')
INFO [stdout] (http-localhost-127.0.0.1-8080-1) [SERVICE] Enlisting a participant into the BA
INFO [stdout] (http-localhost-127.0.0.1-8080-1) [SERVICE] Invoking the back-end business logic
INFO [stdout] (http-localhost-127.0.0.1-8080-1) [SERVICE] Prepare the backend resource and if successful notify the coordinator that we have completed our work
INFO [stdout] (http-localhost-127.0.0.1-8080-1) [SERVICE] Prepare successful, notifying coordinator of completion
INFO [stdout] (http-localhost-127.0.0.1-8080-1) [SERVICE] Participant.confirmCompleted('true') (This tells the participant that compensation information has been logged and that it is safe to commit any changes.)
You can also start the server and deploy the quickstarts or run the Arquillian tests from Eclipse using JBoss tools. For general information about how to import a quickstart, add a WildFly server, and build and deploy a quickstart, see Use JBoss Developer Studio or Eclipse to Run the Quickstarts.
This quickstart is more complex than the others. It requires that you configure the WildFly server to use the standalone-xts.xml configuration file, which is located in an external configuration directory.
Server
tab, right-click and choose New
--> Server
.Select the server type:
, expand Red Hat JBoss Middleware
and choose Red Hat JBoss Enterprise Application Platform 7.x
.Server name
, enter WildFly XTS Configuration
and click Next
.Create a new Server Adapter
dialog, choose Create a new runtime (next page)
and click Next
.JBoss Runtime
dialog, enter the following information and then click Finish
.
Name: WildFly XTS Runtime
Home Directory: (Browse to the server directory and select it)
Execution Environment: (Choose your runtime JRE if not correct)
Configuration base directory: (This should already point to your server configuration directory)
Configuration file: ../../docs/examples/configs/standalone-xts.xml
Start the new WildFly XTS Configuration
server.
wsba-participant-completion-simple
project, choose Run As
--> Maven build
, enter clean verify -Parq-remote
for the Goals:
, and click Run
to run the Arquillian tests. The test results appear in the console.If you want to debug the source code of any library in the project, run the following command to pull the source into your local repository. The IDE should then detect it.
mvn dependency:sources