Tutorial : Building EJB3 Stateless Session Bean and JAX-WS web service In One Class Using RAD 7.5 - Implementation

This series is about building an empty shell application that contains an EJB3 stateless session bean, a JAX-WS web service, and a web application that acts as the EJB and web service clients. I personally built it for performance testing purpose; so I can plug-in "in-doubt" java code to oberve how they handle concurrency in a server environment. But this will serve as a tutorial for those who are interested.

Part 1 : Project Setup
Part 2 : EJB3 and JAX-WS Implementation
Part 3 : Develop EJB3 client
Part 4 : Develop JAX-WS client


Implement the Interface. 

Before we make changes to it, here is the generated class.

package
com.appinf;

import javax.ejb.Remote;
@Remote
public
        interface TestHarnessRemote {
}


After the changes:

 
Here we added a method called runTest, and added WebService annotations.

Implement the Bean class.




The most important thing here is to specify endpointInterface in the WebService annotation. Without it, the class will compile and run, but fail when being called because the web service client needs an Interface instead of an actual class to call the web service.

Also, pay attention to the warning next to the WebService annotation. It reads "This EJB Web Service does not have a router module. Invocation of this web service would fail." This is because a web service needs a web module to process the web service http requests. For that, we need to generate a router module.



Generate a router Module

In Java EE perspective, right click the Service. Click "Create Router Modules (EndpointEnabler).

Accept Default. Click Finish.


A web project Called TestHarness_HTTPRouter is created. Open the web.xml, the url mapping
/TestHarnessService
appended by the default context root TestHarness_HTTPRouter will be the url to call this web service.


Next, we are going to develop clients to test the EJB3 Stateless Session Bean and the JAX-WS web-service.


1 comment: