File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes SOA with EJB3. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "SOA with EJB3." Watch "SOA with EJB3." New topic

SOA with EJB3.

raj parthas

Joined: Jun 11, 2008
Posts: 1
Hi Techies,

I am very eager to know how SOA can be achieved using EJB3. I will just briefly describe the scenario.

I need to have EJBs which needs to be accessed both Locally and Remotely (same method implementation). And also these methods needs to be exposed as a web service, which will be deployed in a seperate web server.

My design idea is,
1 Define a interface with required methods
2. Implement both by the remote and Local beans
3. Have all your implementations in your Local EJBs
4. Have your remote EJBs as just a delegator to your Local EJBs.

In my above approach, am I right in implementing a single interface with both Local & Remote EJBs. Will I be able to call Remote or Local as per my need by its mappedName and Name?
Please clarify.

Thanks a lot in advance.

Akshay Sahu

Joined: Sep 04, 2009
Posts: 26

Hi Raj Parthas,

EJB 3 has internal support for Java Web Services.

Following is the way to expose your EJB 3 compatible enterprise bean as a web service:

import javax.jws.*;
import javax.ejb.Stateless;

class SampleRemoteInterface {
public void sample(String str) {
// Something good should be done here.

1. Just build your EAR file and deploy it into any of the container available.
2. According to EJB 3 Specification, every container should take the definition from the class file and create a wsdl file for it.
3. The container will generate a wsdl URL for you, which can be accessed either from Axis2 or Java 6 SDK.
4. To know more about EJB 3 SOA, just search for @WebService and @WebMethod support on EJB3.

Akshay Sahu

Akshay Sahu
OCBCD (EJB 3), OCJP (Java SE 6), MCTS (MS SQL Server 2005)
I agree. Here's the link:
subject: SOA with EJB3.
It's not a secret anymore!