7 Upgrading WebLogic Web Services

The following sections describe the procedures for upgrading WebLogic Web services from WebLogic Server 9.x or 10.x to the WebLogic Server 12.1.x release. It also describes how to upgrade 8.1 WebLogic Web services to 12.1.x WebLogic Web services.

9.2 and 10.3.x WebLogic Web services (JAX-WS or JAX-RPC) will continue to run, without any changes, on version 12.1.x of WebLogic Server because the associated Web services run time is still supported in this release, although they are deprecated and will be removed from the product in future releases. For this reason, Oracle highly recommends that you follow the instructions in this chapter to upgrade your 9.2 or 10.3.x Web service to 12.1.x.

Upgrading a 10.3.x RESTful Web Service (JAX-RS) to 12.1.x

In 10.3.x, a set of pre-built shared libraries were delivered with WebLogic Server to support Jersey 1.9 and 1.1.5.1 JAX-RS RI. In order to use the shared libraries, you needed to register them with the WebLogic Server instance, and modify the web.xml and weblogic.xml deployment descriptors to use the Jersey servlet and reference the shared libraries, respectively.

The following sections described the steps required to upgrade your environment so that the 10.3.x RESTful Web services run in the 12.1.x environment.

Upgrading a 10.3.x RESTful Web Service That Uses the Jersey 1.9
Shared Libraries

If your 10.3.x RESTful WebLogic Web service uses Jersey 1.9 shared libraries, then no additional steps are required to run the application in the 12.1.x environment. In this case, the Jersey 1.9 JAR file that is present in the system classpath is loaded by the WebLogic Server system classloader.

Note:

If the RESTful Web service application is packaged with a servlet, ensure that it is packaged appropriately based on whether your Web application is using Servlet 3.0 or earlier. For more information, see "Packaging With a Servlet" in Developing RESTful Web Services.

Upgrading a 10.3.x RESTful Web Service That Uses the Jersey 1.1.5.1
Shared Libraries

Note:

The Jersey 1.1.5.1 JAX-RS RI shared libraries are provided for backwards compatibility only. It is recommended that you upgrade your RESTful Web service applications to use the Jersey 1.9 JAX-RS RI APIs that are available on the WebLogic Server system classpath.

For backwards compatibility, the Jersey 1.1.5.1 JAX-RS RI shared libraries are delivered with the 12.1.x release of WebLogic Server. The shared libraries are located in the following directory: WL_HOME/common/deployable-libraries.

Table 7-1 summarizes the pre-built shared libraries that support Jersey JAX-RS RI Version 1.1.5.1 Web services, organized by the functionality that they support. The table also indicates whether the shared library is required or optional.

Table 7-1 Shared Libraries for Jersey JAX-RS RI 1.1.5.1

Functionality

Description

Required?

Jersey

Shared Library Name: jersey-bundle

JAR Filename: jersey-bundle-1.1.5.1.jar

WAR Filename: jersey-bundle-1.1.5.1.war

Version: 1.1.5.1

License: SUN CDDL+GPL

Required

JAX-RS API

Shared Library Name: jsr311

JAR Filename: jsr311-api-1.1.1.jar

WAR Filename: jsr311-api-1.1.1.war

Version: 1.1.1

License: JSR311 license

Required

JSON processing

Shared Library Name: jackson-core-asl

JAR Filename: jackson-core-asl-1.1.1.jar

WAR Filename: jackson-core-asl-1.1.1.war

Version: 1.1.1

License: Apache 2.0

Optional

JSON processing

Shared Library Name: jackson-jaxrs

JAR Filename: jackson-jaxrs-1.1.1.jar

WAR Filename: jackson-jaxrs-1.1.1.war

Version: 1.1.1

License: Apache 2.0

Optional

JSON processing

Shared Library Name: jackson-mapper-asl

JAR Filename: jackson-mapper-asl-1.1.1.jar

WAR Filename: jackson-mapper-asl-1.1.1.war

Version: 1.1.1

License: Apache 2.0

Optional

JSON streaming

Shared Library Name: jettison

JAR Filename: jettison-1.1.jar

WAR Filename: jettison-1.1.war

Version: 1.1

License: Apache 2.0

Optional

ATOM processing

Shared Library Name: rome

JAR Filename: rome-1.0.jar

WAR Filename: rome-1.0.war

Version: 1.0

License: Apache 2.0

Optional

To upgrade your environment so that the 10.3.x RESTful Web services run in the 12.1.x environment and continue to use the Jersey 1.1.5.1 shared libraries, you need to perform the following steps:

Register the Jersey 1.1.5.1 shared libraries with one or more WebLogic Server instances.

Shared Java EE libraries are registered with one or more WebLogic Server instances by deploying them to the target servers and indicating that the deployments are to be shared. Shared Java EE libraries must be targeted to the same WebLogic Server instances you want to deploy applications that reference the libraries.

The following shows an example of how to deploy the shared libraries that provide support for the basic Jersey JAX-RS RI functionality and JAX-RS API.

If the RESTful Web service application is packaged with a servlet, ensure that it is packaged appropriately based on whether your Web application is using Servlet 3.0 or earlier. For more information, see "Packaging With a Servlet" in Developing RESTful Web Services.

Deploy your RESTful Web service application.

Upgrading a 9.2 or 10.x WebLogic Web Service (JAX-WS or JAX-RPC) to 12.1.x

No steps are required to upgrade a 9.2 or 10.x WebLogic Web service to 12.1.x; you can redeploy the JAX-WS or JAX-RPC Web service to WebLogic Server 12.1.x without making any changes or recompiling.

Upgrading a 9.0 or 9.1 WebLogic Web Service (JAX-WS or JAX-RPC) to 12.1.x

If your 9.0/9.1 Web service used any of the following features, then you must recompile the Web service before you redeploy it to WebLogic Server 12.1.x:

If your 9.0/9.1 Web service did not use these features, then you can redeploy it to WebLogic Server 12.1.x without making any changes or recompiling it.

Upgrading an 8.1 WebLogic Web Service to 12.1.x

In the 12.1.1 release, the 8.1 WebLogic Web services run time has been removed. If you are using 8.1 WebLogic Web services, you need to upgrade the 8.1 WebLogic Web service applications to Web service stacks available in this release. The 8.1 WebLogic Web services rely on Apache XMLBeans for the purpose of mapping XML elements in SOAP payloads into Java objects and vice versa. XMLBeans are not supported in 12.1.1. The following upgrade paths are available:

Upgrade to the JAX-WS stack: This is the best upgrade path from the standpoint of taking advantage of latest technologies and standard support in WebLogic Server. This path requires a manual upgrade process, and the level of effort is determined by the nature of the existing 8.1 Web service applications. For example, if the applications have little XMLBeans usage, then the upgrade process is relatively easy. For 8.1 Web Service applications with heavy XMLBeans dependencies, you must modify the business logic in the service implementation in order to use JAXB classes instead of XMLBeans classes. Please note that JAX-WS does not support RPC-encoded style, and 8.1 Web Service applications with RPC-encoded style will need to adopt more interoperable literal style service contracts. For more information, see "Upgrading an 8.1 WebLogic Web Service to the WebLogic JAX-WS Stack".

Upgrading an 8.1 WebLogic Web Service to the WebLogic JAX-RPC Stack

This section describes how to upgrade an 8.1 WebLogic Web service to use the WebLogic JAX-RPC run-time environment. The WebLogic JAX-RPC run time is based on the JSR 109: Implementing Enterprise Web Services specification at http://www.jcp.org/en/jsr/detail?id=109. The 12.1.x programming model uses standard JDK 1.5 metadata annotations, as specified by the JSR 181: Web Services Metadata for the Java Platform specification (JSR-181) at http://www.jcp.org/en/jsr/detail?id=181.

Upgrading your 8.1 Web service includes the following high-level tasks; the procedures in later sections go into more detail:

Update the 8.1 Java source code of the Java class or stateless session EJB that implements the Web service so that the source code uses JWS annotations.

In 12.1.x, WebLogic Web services are implemented using JWS files, which are Java files that contains JWS annotations. The jwsc Ant Task always implements the Web service as a plain Java file unless you explicitly implement javax.ejb.SessionBean in your JWS file. This latter case is not typical. This programming model differs from that of 8.1, where you were required to specify the type of back-end component (Java class or EJB).

Update the Ant build script that builds the Web service to call the 12.1.x WebLogic Web service Ant task jwsc instead of the 8.1 servicegen task.

In the sections that follow it is assumed that:

You previously used servicegen to generate your 8.1 Web service and that, more generally, you use Ant scripts in your development environment to iteratively develop Web services and other Java Platform, Enterprise Edition (Java EE) Version 5 artifacts that run on WebLogic Server. The procedures in this section direct you to update existing Ant build.xml files.

You have access to the Java class or EJB source code for your 8.1 Web service.

This section does not discuss the following topics:

Upgrading a JMS-implemented 8.1 Web service, because the WebLogic Web services JAX-RPC run time does not support JMS-implemented services.

Upgrading Web services from versions previous to 8.1.

Upgrading a client application that invokes an 8.1 Web service to one that invokes a 12.1.x Web service. For details on how to write a client application that invokes a 12.1.x Web service, see "Invoking Web Services" in Getting Started With JAX-RPC Web Services for Oracle WebLogic Server.

Upgrading an 8.1 Java Class-Implemented WebLogic Web Service
to 12.1.x: Main Steps

To upgrade an 8.1 Java class-implemented Web service to use the WebLogic Web services JAX-RPC run time:

Open a command window and set your WebLogic Server 12.1.x environment by executing the setDomainEnv.cmd (Windows) or setDomainEnv.sh (UNIX) script, located in the bin subdirectory of your 12.1.x domain directory.

The default location of WebLogic Server domains is MW_HOME/user_projects/domains/domainName, where MW_HOME is the top-level installation directory of the Oracle products and domainName is the name of your domain.

Create a project directory:

prompt> mkdir /myExamples/upgrade_pojo

Create a src directory under the project directory, as well as sub-directories that correspond to the package name of the new 12.1.x JWS file (shown later in this procedure) that corresponds to the old 8.1 Java class:

If needed, change the package name and class name of the Java file to reflect the new 12.1.x source environment.

Add import statements to import both the standard and WebLogic-specific JWS annotations.

Add, at a minimum, the following JWS annotation:

The standard @WebService annotation at the Java class level to specify that the JWS file implements a Web service.

Oracle recommends you also add the following annotations:

The standard @SOAPBinding annotation at the class-level to specify the type of Web service, such as document-literal-wrapped or RPC-encoded.

The WebLogic-specific @WLHttpTransport annotation at the class-level to specify the context and service URIs that are used in the URL that invokes the deployed Web service.

The standard @WebMethod annotation at the method-level for each method that is exposed as a Web service operation.

See "Programming the JWS File" in Getting Started With JAX-RPC Web Services for Oracle WebLogic Server for general information about using JWS annotations in a Java file.

You might need to add additional annotations to your JWS file, depending on the 8.1 Web service features you want to carry forward to 12.1.x. In 8.1, many of these features were configured with attributes of servicegen. See Mapping of servicegen Attributes to JWS Annotations or jwsc Attributes for a table that lists equivalent JWS annotation, if available, for features you enabled in 8.1 using servicegen attributes.

Copy the old build.xml file that built the 8.1 Web service to the 12.1.x working directory.

Update your Ant build.xml file to execute the jwsc Ant task, along with other supporting tasks, instead of servicegen.

Oracle recommends that you create a new target, such as build-service, in your Ant build file and add the jwsc Ant task call to compile the new JWS file you created in the preceding steps. Once this target is working correctly, you can remove the old servicegen Ant task.

The following procedure lists the main steps to update your build.xml file; for details on the steps, see the standard iterative development process outlined in "Developing WebLogic Web Services" in Getting Started With JAX-RPC Web Services for Oracle WebLogic Server.

Create a build-service target and add the tasks needed to build the 12.1.x Web service, as described in the following steps.

Add the jwsc task to the build file. Set the srdir attribute to the src directory (/myExamples/upgrade_pojo/src, in this example) and the destdir attribute to the root Enterprise application directory you created in the preceding step.

Set the file attribute of the <jws> child element to the name of the new JWS file, created earlier in this procedure.

You may need to specify additional attributes to the jwsc task, depending on the 8.1 Web service features you want to carry forward to 12.1.x. In 8.1, many of these features were configured using attributes of servicegen. See Mapping of servicegen Attributes to JWS Annotations or jwsc Attributes for a table that describes if there is an equivalent jwsc attribute for features you enabled using servicegen attributes.

Based on the sample Java code shown in the following sections, the URL to invoke the WSDL of the upgraded 12.1.x Web service is:

http://host:port/upgradePOJO/HelloWorld?WSDL

Example of an 8.1 Java File and the Corresponding 12.1.x JWS File

Assume that the following sample Java class implemented a 8.1 Web service:

package examples.javaclass;
/**
* Simple Java class that implements the HelloWorld Web service. It takes
* as input an integer and a String, and returns a message that includes these
* two parameters.
*/
public final class HelloWorld81 {
/**
* Returns a text message that includes the integer and String input
* parameters.
*
*/
public String sayHello(int num, String s) {
System.out.println("sayHello operation has been invoked with arguments " + s + " and " + num);
String returnValue = "This message brought to you by the letter "+s+" and the number "+num;
return returnValue;
}
}

The following simple build.xml file shows the 8.1 way to build a WebLogic Web service using the servicegen Ant task; in the example, the Java file that implements the 8.1 Web service has already been compiled into the examples.javaclass.HelloWorld81 class:

An equivalent build.xml file that calls the jwsc Ant task to build a 12.1.x Web service is shown below, with the relevant tasks discussed in this section in bold. In the example, the new JWS file that implements the 12.1.x Web service is called HelloWorld92Impl.java:

Upgrading an 8.1 EJB-Implemented WebLogic Web Service to
12.1.x: Main Steps

The following procedure describes how to upgrade an 8.1 EJB-implemented Web service to use the WebLogic Web services JAX-RPC run time.

The 12.1.x Web services programming model is quite different from the 8.1 model in that it hides the underlying implementation of the Web service. Rather than specifying up front that you want the Web service to be implemented by a Java class or an EJB, the jwsc Ant task always picks a plain Java class implementation, unless you have explicitly implemented javax.ejb.SessionBean in the JWS file, which is not typical. For this reason, the following procedure does not show how to import EJB classes or use EJBGen, even though the 8.1 Web service was explicitly implemented with an EJB. Instead, the procedure shows how to create a standard JWS file that is the 12.1.x equivalent to the 8.1 EJB-implemented Web service.

Open a command window and set your 12.1.x WebLogic Server environment by executing the setDomainEnv.cmd (Windows) or setDomainEnv.sh (UNIX) script, located in the bin subdirectory of your 12.1.x domain directory.

The default location of WebLogic Server domains is MW_HOME/user_projects/domains/domainName, where MW_HOME is the top-level installation directory of the Oracle products and domainName is the name of your domain.

Create a project directory:

prompt> mkdir /myExamples/upgrade_ejb

Create a src directory under the project directory, as well as sub-directories that correspond to the package name of the new 12.1.x JWS file (shown later on in this procedure) that corresponds to your 8.1 EJB implementation:

If needed, change the package name and class name of the Java file to reflect the new 12.1.x source environment.

Optionally remove the import statements that import the EJB classes (javax.ejb.*). These classes are no longer needed in the upgraded JWS file.

Add import statements to import both the standard and WebLogic-specific JWS annotations.

Ensure that the JWS file does not implement javax.ejb.SessionBean anymore by removing the implements SessionBean code from the class declaration.

Remove all the EJB-specific methods:

ejbActivate()

ejbRemove()

ejbPassivate()

ejbCreate()

Add, at a minimum, the following JWS annotation:

The standard @WebService annotation at the Java class level to specify that the JWS file implements a Web service.

Oracle recommends you also add the following annotations:

The standard @SOAPBinding annotation at the class-level to specify the type of Web service, such as document-literal-wrapped or RPC-encoded.

The WebLogic-specific @WLHttpTransport annotation at the class-level to specify the context and service URIs that are used in the URL that invokes the deployed Web service.

The standard @WebMethod annotation at the method-level for each method that is exposed as a Web service operation.

See "Programming the JWS File" in Getting Started With JAX-RPC Web Services for Oracle WebLogic Server for general information about using JWS annotations in a Java file.

You might need to add additional annotations to your JWS file, depending on the 8.1 Web service features you want to carry forward to 12.1.x. In 8.1, many of these features were configured using attributes of servicegen. See Mapping of servicegen Attributes to JWS Annotations or jwsc Attributes for a table that lists equivalent JWS annotation, if available, for features you enabled in 8.1 using servicegen attributes.

Copy the old build.xml file that built the 8.1 Web service to the 12.1.x working directory.

Update your Ant build.xml file to execute the jwsc Ant task, along with other supporting tasks, instead of servicegen.

Oracle recommends that you create a new target, such as build-service, in your Ant build file and add the jwsc Ant task call to compile the new JWS file you created in the preceding steps. Once this target is working correctly, you can remove the old servicegen Ant task.

The following procedure lists the main steps to update your build.xml file; for details on the steps, see the standard iterative development process outlined in

Create a build-service target and add the tasks needed to build the 12.1.x Web service, as described in the following steps.

Add the jwsc task to the build file. Set the srdir attribute to the src directory (/myExamples/upgrade_ejb/src, in this example) and the destdir attribute to the root Enterprise application directory you created in the preceding step.

Set the file attribute of the <jws> child element to the name of the new JWS file, created earlier in this procedure.

You may need to specify additional attributes to the jwsc task, depending on the 8.1 Web service features you want to carry forward to 12.1.x. In 8.1, many of these features were configured using attributes of servicegen. See Mapping of servicegen Attributes to JWS Annotations or jwsc Attributes for a table that indicates whether there is an equivalent jwsc attribute for features you enabled using servicegen attributes.

8.1 SessionBean Class

package examples.statelessSession;
import javax.ejb.CreateException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
/**
* HelloWorldBean is a stateless session EJB. It has a single method,
* sayHello(), that takes an integer and a String and returns a String.
* <p>
* The sayHello() method is the public operation of the Web service based on
* this EJB.
*/
public class HelloWorldBean81 implements SessionBean {
private static final boolean VERBOSE = true;
private SessionContext ctx;
// You might also consider using WebLogic's log service
private void log(String s) {
if (VERBOSE) System.out.println(s);
}
/**
* Single EJB business method.
*/
public String sayHello(int num, String s) {
System.out.println("sayHello in the HelloWorld EJB has "+
"been invoked with arguments " + s + " and " + num);
String returnValue = "This message brought to you by the "+
"letter "+s+" and the number "+num;
return returnValue;
}
/**
* This method is required by the EJB Specification,
* but is not used by this example.
*
*/
public void ejbActivate() {
log("ejbActivate called");
}
/**
* This method is required by the EJB Specification,
* but is not used by this example.
*
*/
public void ejbRemove() {
log("ejbRemove called");
}
/**
* This method is required by the EJB Specification,
* but is not used by this example.
*
*/
public void ejbPassivate() {
log("ejbPassivate called");
}
/**
* Sets the session context.
*
* @param ctx SessionContext Context for session
*/
public void setSessionContext(SessionContext ctx) {
log("setSessionContext called");
this.ctx = ctx;
}
/**
* This method is required by the EJB Specification,
* but is not used by this example.
*
*/
public void ejbCreate () throws CreateException {
log("ejbCreate called");
}
}

8.1 Remote Interface

package examples.statelessSession;
import java.rmi.RemoteException;
import javax.ejb.EJBObject;
/**
* The methods in this interface are the public face of HelloWorld.
* The signatures of the methods are identical to those of the EJBean, except
* that these methods throw a java.rmi.RemoteException.
*/
public interface HelloWorld81 extends EJBObject {
/**
* Simply says hello from the EJB
*
* @param num int number to return
* @param s String string to return
* @return String returnValue
* @exception RemoteException if there is
* a communications or systems failure
*/
String sayHello(int num, String s)
throws RemoteException;
}

Example of an 8.1 and Updated 12.1.x Ant Build File for an 8.1
EJB-Implemented Web Service

The following simple build.xml file shows the 8.1 way to build an EJB-implemented WebLogic Web service using the servicegen Ant task. Following this example is an equivalent build.xml file that calls the jwsc Ant task to build a 12.1.x Web service.

Mapping of servicegen Attributes to JWS Annotations or jwsc Attributes

The following table maps the attributes of the 8.1 servicegen Ant task to their equivalent 12.1.x JWS annotation or jwsc attribute.

The attributes listed in the first column are a mixture of attributes of the main servicegen Ant task and attributes of the four child elements of servicegen (<service>, <client>, <handlerChain>, and <security>)

See "JWS Annotation Reference" and "jwsc" in the WebLogic Web Services Reference for Oracle WebLogic Server for more information about the 12.1.x JWS annotations and jwsc Ant task.

Upgrading an 8.1 WebLogic Web Service to the WebLogic JAX-WS Stack

This section summarizes how to upgrade an 8.1 WebLogic Web service to use the WebLogic JAX-WS stack.

The WebLogic JAX-WS run time is based on the JAX-WS (The Java API for XML-Based Web Services) 2.2 specification and the Web Services for Java EE v1.3 (JSR 109) specifications. These define annotations that are used in a Java Web Service (JWS) source file to define a Web service. Ant tasks are then used to compile the JWS into a Java class and generate all the associated artifacts. The Java Web Service (JWS) is the core of your JAX-WS web service.

Upgrading your 8.1 Web service includes the following high-level tasks:

Upgrade any Web service EJBs from 2.x to 3.x.

JAX-WS supports EJB 3.0 and 3.x. It does not support EJB 2.x.

Rewrite the 8.1 Web service class as a JAX-WS JWS file and map any proprietary 8.x features to similar JAX-WS features.

Note that there is not a one-to-one correspondence between 8.1 Web service features and JAX-WS 12.1.x features.

Update the Ant build script that builds the Web service to call the 12.1.x WebLogic Web service Ant task jwsc instead of the 8.1 servicegen task.

Generate new JAX-WS clients using the JAX-WS clientgen Ant task.

JAX-WS Upgrade Considerations

Before upgrading to JAX-WS, you should consider the following:

The JAX-WS specification supports the "document-literal" and "rpc-literal" styles, but not "rpc-encoded". If you require rpc-encoded, you should consider upgrading your 8.1 Web service to the JAX-RPC model, rather than JAX-WS.

SOAP Arrays are not supported by JAX-WS; they are available in JAX-RPC.