Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide 10g (10.1.3.5.0) Part Number E13981-01 |
|
|
View PDF |
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:
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
).
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.
For information on looking up and using a Web service, see "Using EJB and Web Services".