Adding Web service references (J2EE 1.4)

Starting with the J2EE 1.3 specification, application components (application clients, Web modules, EJB modules) can define references to external Web services by using "logical" names called Web service references. In J2EE 1.3, the references are added to a webservicesclient.xml in a module. Beginning with J2EE 1.4, the reference is included in the deployment descriptor. You can use the deployment descriptor editor todefine a web service reference.

About this task

At deployment, the Web service references are bound to the Web service interfaces in the target operational environment.

For each Web service reference that you define, a service-ref element is added to that application component. Web service references are scoped to the application component or enterprise bean where they are defined, so they are not accessible to other application components or beans during run time. Other components can define Web service references with the same name without causing a name conflict.

Note: For project levels previous to the J2EE 1.4 specification level, the workbench allows you to define Web service references, but the service-ref elements are not added to the deployment descriptors (the application-client.xml, web.xml, or ejb-jar.xml). Rather, the Web service references are declared in a webservicesclient.xml file in the WEB-INF folder of the module. For example, if you add a Web service reference to a J2EE 1.3 application client, the reference is added to webservicesclient.xml. If you add a Web service reference to a J2EE 1.4 application client, the reference is added to application-client.xml.
Tip: The EJB specification recommends that you organize all Web service references in the service sub-context of the bean's environment, the java:comp/env/service JNDI context.

Procedure

  1. Open the Add Reference wizard from the deployment descriptor editor for your J2EE project.
  2. Select Service reference and click Next.
  3. From the list of Web services in your workspace, select the Web service that you want to reference. A default name appears in the Name field that you can change. This is used as the name for the reference in the service-ref-name entry in the deployment descriptor.

    Click Next.

  4. In the Description text area, enter a description for the reference.
  5. In the Namespace URI field, enter a new namespace URI. The value entered in this field is used as the xmlns:prefix attribute in the service-qname entry in the deployment descriptor.
  6. In the Local part field, indicate whether the message destination consumes or produces messages. The value entered in this field is used as the value in the service-qname entry in the deployment descriptor:
    <service-qname xmlns:prefix="http://service.directory">
    		prefix:EmployeeDirectoryService
    </service-qname>
  7. Click Finish.

Feedback