Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SOA with EJB3.

 
raj parthas
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Cheers,
Raj
SCJP, SCBCD
 
Akshay Sahu
Greenhorn
Posts: 26
Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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;

@WebService
@Stateless
class SampleRemoteInterface {
@WebMethod
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.

Regards,
Akshay Sahu
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic