File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Services and the fly likes Webservice and remote ejbs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Webservice and remote ejbs" Watch "Webservice and remote ejbs" New topic

Webservice and remote ejbs

Bob Randall

Joined: Jun 01, 2006
Posts: 5
I have a requirement to call a remote ejb y in a different ear through ejb x in another ear using webservices on weblogic.

I have some of the steps for using ejb y as a remote service

create the stateless bean y remote interface, bean, home

For exposing the bean y as Web service endpoint interface

Do I need an entry <service-endpoint></service-endpoint> in ejb-jar.xml.

Use weblogic servicegen ant task to generate web-services.xml and put it in ear file specify ejb jar serviceName serviceURI targetNamespace

The webservices.xml looks like

<weblogic-webservices xmlns="">

My question is that from x bean can I use JAX-RPC to access y bean and if yes can I have some code sample.
Peer Reynders

Joined: Aug 19, 2005
Posts: 2933
Originally posted by Bob Randall:
Do I need an entry <service-endpoint></service-endpoint> in ejb-jar.xml.

  • y -> service provider
  • x -> service consumer

  • You will need a <service-endpoint> entry in the service provider ejb-jar.xml. The interface specified there must match the one listed in the webservices.xml <service-endpoint-interface> entry.

    The webservices.xml <port-component> entry is also supposed to contain a <service-endpoint-interface> entry which specifies the same interface listed in the <service-endpoint> entry in the ejb-jar.xml. Furthermore you need an <service-impl-bean> entry which contains an <ejb-link> to the implementing ejb.

    (service provider) webservices.xml excerpt

    (service provider) ejb-jar.xml excerpt

    (service consumer) ejb-jar.xml excerpt

    Originally posted by Bob Randall:
    My question is that from x bean can I use JAX-RPC to access y bean

    Yes - however I suspect not in the manner that you are hoping. The J2EE 1.4 specification only guarantees that you can expose an SLSB as a web service and it guarantees that an EJB can access a web service. It does not guarantee that the EJB security and transaction semantics are maintained when an EJB accesses another EJB over a web services interface.

    J2EE 1.4 does not provide for the propagation of EJB security and transactions over a web services connection.

    Theoretically a vendor extension could propagate transactions through the use of WS-T ((Web services transactions)) and security information in SOAP headers or the HTTP session. In most cases however the service provider EJB simply manages its own transactions and its methods are simply exposed with <unchecked/>. It is possible to write your own JAX-RPC server and client side handlers so that you can perform your own client authentication before letting the call go through.

    From the perspective of the service consumer EJB calling an EJB-based endpoint is no different than calling a servlet-based endpoint.
    I agree. Here's the link:
    subject: Webservice and remote ejbs
    It's not a secret anymore!