Skip Headers
Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide
10g (10.1.3.5.0)

Part Number E13981-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

Configuring an Environment Reference to a Web Service

You can access a Web service from a stateless session bean by creating a resource manager connection factory reference to the Web service.

Note:

In EJB 3.0, an environment reference to a Web service is not needed. You can access a Web service directly using annotations and resource injection.

For each client, in which you want to access a resource manager connection factory, you must either inject it in the client source code, or define an environment reference to it in the client's deployment descriptor.

To create an environment reference to a Web service, do the following:

  1. Define a logical name for the Web service.

    Define a <service-ref> element in the appropriate client deployment descriptor (see "Where do you Configure an EJB Environment Reference?") and configure the following subelements:

    • <service-ref-name>: a logical name for the Web service.

    • <service-interface>: the Web service interface.

    Example 19-18 shows a <service-ref> element for a Web service.

    It is a best practice to start the reference name with service, but it is not required. In the bean code, the lookup of this reference (see Example 30-5) is always prefaced by java:comp/env (for example, java:comp/env/service/myService).

    Example 19-18 ejb-jar.xml For a Web Service Logical Name

    <service-ref>
        <service-ref-name>service/StockQuoteService</service-ref-name>
        <service-interface>com.example.StockQuoteService</service-interface>
    </service-ref>
    
  2. Map the logical name to the actual JNDI name.

    Define a <service-ref-mapping> element in the corresponding OC4J-specific deployment descriptor (see "Where do you Configure an EJB Environment Reference?") and configure its name attribute to the Web service logical name (defined in the <service-ref>) and the <service-qname> subelement.

    Example 19-15 shows a <service-ref-mapping> element for a Web service.

    Example 19-19 orion-ejb-jar.xml For a Web Service Logical to JNDI Mapping

    <service-ref-mapping name="service/WebServiceBroker">
        <service-qname namespaceURI="urn:WebServiceBroker" localpart="WebServiceBroker"/>
    </service-ref-mapping>
    

For information on looking up and using a Web service, see "Using EJB and Web Services".