• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Web Services for EJB Session Beans

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Pawan Pangty
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This article shows that you can expose an EJB 2.0 SLSB as a webservice.
 
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Excerpt from EJB 2.0 Development with Websphere Studio Application Developer IBM Redbook.
 
Watsh Rajneesh
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 2968
6
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your suggestion. I will go through the documentation again hoping to find resolution to my problem.
 
Pawan Pangty
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic