GeeCON Prague 2014*
The moose likes Web Services and the fly likes Web Services for EJB Session Beans Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Web Services
Bookmark "Web Services for EJB Session Beans" Watch "Web Services for EJB Session Beans" New topic
Author

Web Services for EJB Session Beans

Pawan Pangty
Greenhorn

Joined: Aug 03, 2004
Posts: 8
Hi all,

I need to create a WEB SERVICE for my session bean .
The session bean in turn calls an Entity bean.Service Locator is used for the lookup etc.
Actually, I want to expose all my stateless session beans in the Business layer as Web Services.

For the time being, I have gone with the following approach, which results in exception.
I generated a WSDL for the Session Bean using a customized SEI for the required methods
in the Session Bean.
The WSDL and the necessary classes were created in my Web Layer.
Then, I created the proxy classes from the WSDL for the stub implementation.

Everything is right till here..
I access the stub to access the Session Bean methods.
In the Session Bean method, I look for Entity Bean JNDI name.
The code blasts here, saying that it could not find the Entity Bean with that JNDI name.
However, my Entity Bean works fine when tested individually in IBM WSAD server.
It fails, when I call it from the Session Bean.

I have observed one thing over here.
I dont lookup for the Session Bean JNDI name while calling the Session Bean from my stubs.
Is this the problem, then can someone please guide me on this.

Thanks in advance.
Regards,
Pawan
Watsh Rajneesh
Ranch Hand

Joined: Apr 17, 2006
Posts: 110
When you are calling the session bean service endpoint then you can rely on the stub to connect to the service endpoint using the port address as mentioned in the wsdl. So there isnt any need to lookup the session bean. But when your web layer is colocated with your business layer on the same host then probably calling the session bean using the local interface will be more efficient and in which case you will want to not use the webservice messaging between your web and business layer and will just rely on RMI/IIOP (again you wont need to lookup). Also, if your web and business layers are not colocated, using RMI/IIOP will be more efficient than web services (and you will use the remote interface and lookup your session bean home object). Web services will be useful for cross application integration purposes or when you want your services to be directly accessed (not via the web layer) on the internet.


SCJP 5.0 (90%), SCDJWS 1.4 (88%), SCWCD 1.4 (82%), SCBCD 1.3 (85%)
Pawan Pangty
Greenhorn

Joined: Aug 03, 2004
Posts: 8
Hey Rajneesh,

Thanks for the very descriptive reply.
Actually, my intention is to expose the Sesison Beans as Web Services for cross application integration.

Presently, my working model includes a work around for the above exception.
I have created additional service classes in my web layer to call the Session Bean methods.
These classes are exposed as the Web Services for the MS and java clients.

So, in a nutshell, I have a web router, which exposes the Web Services for the service classes.
These service classes in turn call the Session Bean methods using the remote interface and service locator.

I have used the WebSphere Studio Application Developer 5.1.0, which supports j2ee 1.3 and EJB 2.0.

From an article, I have read, it says that EJB 2.1 supports Web Services.
If, it is so, the what about EJB 2.0?

My work around through the web router does work fine.
But, I want do implement the same by directly exposing the Session Beans of the Business layer as Web Services for cross platform integration.

Any tips / solutions for the same?

Thanks in advance.
Pawan
Watsh Rajneesh
Ranch Hand

Joined: Apr 17, 2006
Posts: 110
This article shows that you can expose an EJB 2.0 SLSB as a webservice.
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
Originally posted by Pawan Pangty:

From an article, I have read, it says that EJB 2.1 supports Web Services.
If, it is so, the what about EJB 2.0?


Originally posted by Watsh Rajneesh:
This article shows that you can expose an EJB 2.0 SLSB as a webservice.


Basically in a J2EE 1.3 (EJB 2.0) compliant application server support for web services relies on the use of non-portable vendor extensions, provided that web services are supported at all. In a J2EE 1.4 (EJB 2.1) compliant application server EJB Web Service support is mandatory through the service endpoint API of EJB 2.1 and JAX-RPC.

So a solution for J2EE 1.3 Oracle Application Server is likely to look quite different from the J2EE 1.3 IBM Websphere solution as each may use a proprietary, non-portable API rather than EJB 2.1 service endpoints and JAX-RPC. A solution for the J2EE 1.4 versions of both application servers will look much more similar as they both could use the service end point API of EJB 2.1 and JAX-RPC.

For the J2EE 1.4 (EJB 2.1) solution see EJB 2.1 Web Services: Part1.
Watsh Rajneesh
Ranch Hand

Joined: Apr 17, 2006
Posts: 110
Excerpt from EJB 2.0 Development with Websphere Studio Application Developer IBM Redbook.
Watsh Rajneesh
Ranch Hand

Joined: Apr 17, 2006
Posts: 110
Excerpt from EJB 2.0 Development with Websphere Studio Application Developer IBM Redbook. This chapter addresses webservices development using session beans in WSAD 5.x.
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
Talking about IBM Redbooks...

EJB 2.0 Development with WebSphere Studio Application Developer
Web Services Wizardry with WebSphere Studio Application Developer
Self-Study Guide: WebSphere Studio Application Developer and Web Services
WebSphere Version 5.1 Application Developer 5.1.1 Web Services Handbook

IBM Web Services Redbooks
[ August 30, 2006: Message edited by: Peer Reynders ]
Sara Fox
Greenhorn

Joined: Aug 28, 2006
Posts: 11
Can anyone please suggest similar articles (refering to calling a web service for EJB Stateless Session Bean from client JSP) for Weblogic 8.1?
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
Originally posted by Sara Fox:
Can anyone please suggest similar articles (refering to calling a web service for EJB Stateless Session Bean from client JSP) for Weblogic 8.1?


The information is scattered throughout the documentation
Introduction to WebLogic Web Services
Designing WebLogic Web Services
Implementing WebLogic Web Services
etc.

There are supposed to be examples under:
WL_HOME/samples/server/examples/src/examples/webservices
* basic.statelessSession: Uses a stateless session EJB back-end component with built-in data types as its parameters and return value.
* complex.statelessSession: Uses a stateless session EJB back-end component with non-built-in data types as its parameters and return value.

Have a look at
WL_HOME/samples/server/examples/src/examples/webservices/package-summary.html
Sara Fox
Greenhorn

Joined: Aug 28, 2006
Posts: 11
Thanks for your suggestion. I will go through the documentation again hoping to find resolution to my problem.
Pawan Pangty
Greenhorn

Joined: Aug 03, 2004
Posts: 8
Hi all,

I managed to resolve the entity bean JNDI lookup exception.
Now, I am able to expose the Session Beans as the Webservices directly.

Actually, I had not provided Entity Bean reference in the web.xml file present in the Web layer.I missed this part and it was required.

Making the Webservices calls directly relates to the Session Bean methods.
So, session bean JNDI was lookup not required.

This Entity Bean call made in the Session Bean method was indirectly routed by the Webservice Interface present in the Web layer.

So, I provided the reference of the Entity Bean in the web.xml file of the Web Layer.This worked.

Hope this workaround sounds reasonable.

Thanks for the helpful links and comments.

Regards,
Pawan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Web Services for EJB Session Beans