uCosminexus Application Server, Web Service Development Guide

[Contents][Glossary][Index][Back][Next]

Appendix B. Migrating from the POJO Web Service to the EJB Web Service

You can use the EJB functionality by operating the Web Service developed in POJO as an EJB Web Service. This appendix describes how to migrate the POJO Web Service to the EJB Web Service. Note that when the POJO Web Service is adequate, migration to EJB is not required.

The following table describes how to migrate the POJO Web Service to the EJB Web Service:

Table B-1 How to migrate to the EJB Web Service

No. Components of the POJO Web Service How to migrate to the EJB Web Service
1 Web Service Implementation Class Add javax.ejb.Stateless annotation in the source code and compile.
2 Java class other than No.1 (SEI, JavaBeans class (Stub)) You can use the class file as is even after migrating to the EJB Web Service.
3 WSDL The URL that is published as a Web Service differs in the POJO Web Service and the EJB Web Service. Therefore, change the URL related values for the location attributes of soap:address element, and then use. For the URL of EJB, see 10.2.2(1) Discovery.
4 DD such as cosminexus-jaxws.xml, web.xml, and application.xml You cannot use the DD created for the POJO Web Service as is in the EJB Web Service. Create a new DD for the EJB Web Service.

While migrating the POJO Web Service to the EJB Web Service, you must modify the source code of the Web Service Implementation Class. The description in this section assumes that the class files required for the execution of the POJO Web Service and the source code required for the Web Service Implementation Class are already available.

The following is the procedure for migration:

Organization of this section
(1) Creating the EJB Web Service Implementation Class
(2) Diverting the class files required for executing the Web Service and the WSDL
(3) Creating a EJB JAR file
(4) Creating a Deployment descriptor
(5) Creating a EAR file

(1) Creating the EJB Web Service Implementation Class

Annotate in the source code of a POJO Web Service Implementation Class by using the javax.ejb.Stateless annotation. Compile the annotated source code and create the class file.

(2) Diverting the class files required for executing the Web Service and the WSDL

You can also use the class files of SEI and JavaBean class (stub) required for executing the POJO Web Service when executing as an EJB Web Service.

If WSDL used for executing the POJO Web Service exists, these files can be used for executing the EJB Web Service as well. However, because the URL published as a Web Service differs when executing the POJO Web Service as an EJB Web Service, change and then use the URL related values for the location attributes of soap:address element of WSDL. For the URL of the EJB Web Service, see 10.2.2(1) Discovery.

(3) Creating a EJB JAR file

Store the class files and WSDL of (1) (2) in the EJB JAR file. For the configuration of the EJB JAR file, see 3.5.2 Configuring EJB JAR files.

(4) Creating a Deployment descriptor

Create application.xml that specifies the EJB JAR file created in (3). The following is an example of application.xml. Specify the name of the EJB JAR file created in (3) in statelessjava.jar.

<?xml version="1.0" encoding="UTF-8"?>
<application version="6" xmlns="http://java.sun.com/xml/ns/javaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd">
 
  <description>Sample application &quot;statelessjava_dynamic_generate&quot;</description>
  <display-name>Sample_application_statelessjava_dynamic_generate </display-name>
  <module>
    <ejb>statelessjava_dynamic_generate.jar</ejb>
  </module>
</application>

For creating application.xml of version 5, set up the version attribute of the application element to 5 and the second location information of the xsd:schemaLocation attribute to http://java.sun.com/xml/ns/javaee/application_5.xsd.

In EJB Web Service, create web.xml while adding settings of the Servlet filter to web.xml. For details, see 3.5.4 Creating WAR file for settings of EJB Web Service. Also, cosminexus-jaxws.xml does not apply to the EJB Web Service.

(5) Creating a EAR file

Create an EAR file containing the EJB JAR files created in (3) (4) and application.xml. For EAR file configuration , see 3.5.3 Creating EAR files.