Introducing WebLogic Web Services
Overview of WebLogic Web Services
The following sections provide an overview of WebLogic Web Services as implemented by WebLogic Server:
- Why Use Web Services?
- Anatomy of a WebLogic Web Service
- How Do I Choose Between JAX-WS and JAX-RPC?
- Roadmap for Implementing WebLogic Web Services
- New and Changed Features in this Release
Why Use Web Services?
Major benefits of Web Services include:
- Interoperability among distributed applications that span diverse hardware and software platforms
- Easy, widespread access to applications through firewalls using Web protocols
- A cross-platform, cross-language data model (XML) that facilitates developing heterogeneous distributed applications
Because you access Web Services using standard Web protocols such as XML and HTTP, the diverse and heterogeneous applications on the Web (which typically already understand XML and HTTP) can automatically access Web Services and communicate with each other.
These different systems can be...
- Microsoft SOAP ToolKit clients
- Java Platform, Enterprise Edition (Java EE) Version 5 applications
- legacy applications
They are written in Java, C++, Perl, and other programming languages. Application interoperability is the goal of Web Services and depends upon the service provider's adherence to published industry standards.
Anatomy of a WebLogic Web Service
WebLogic Web Services are implemented according to the Web Services for Java EE 1.2 specification, which defines the standard Java EE runtime architecture for implementing Web Services in Java. The specification also describes a standard Java EE Web Service packaging format, deployment model, and runtime services, all of which are implemented by WebLogic Web Services.
The following sections describe:
The Programming Model—Metadata Annotations
The Web Services for Java EE 1.2 specification describes that a Java EE Web Service is implemented by one of the following components:
The code in the Java class or EJB implements the business logic of your Web Service. Oracle recommends that, instead of coding the raw Java class or EJB directly, you use the JWS annotations programming model, which makes programming a WebLogic Web Service much easier.
This programing model takes advantage of the new JDK 5.0 metadata annotations feature in which you create an annotated Java file and then use Ant tasks to compile the file into a Java class and generate all the associated artifacts. The Java Web Service (JWS) annotated file is the core of your Web Service. It contains the Java code that determines how your Web Service behaves. A JWS file is an ordinary Java class file that uses annotations to specify the shape and characteristics of the Web Service. The JWS annotations you can use in a JWS file include the standard ones defined by the Web Services Metadata for the Java Platform specification as well as a set of other standard or WebLogic-specific annotations, depending on the type of Web Service you are creating.
This release of WebLogic Server supports...
JAX-RPC, an older specification, defined APIs and conventions for supporting XML Web Services in the Java Platform as well support for the WS-I Basic Profile 1.0 to improve interoperability between JAX-RPC implementations. JAX-WS is a follow up to JAX-RPC 1.1.
For more information, see How Do I Choose Between JAX-WS and JAX-RPC?.
You can specify that the SOAP messages be digitally signed and encrypted (WS-Security) using WS-Policy files.
The Compilation Model—jwsc Ant Task
After you create the JWS file, you use the jwsc WebLogic Web Service Ant task to compile the JWS file, as described by the Web Services for Java EE 1.2 specification.
The jwsc Ant task always compiles the JWS file into a plain Java class; the only time it implements a stateless session EJB is if you implement a stateless session EJB in your JWS file. The jwsc Ant task also generates all the supporting artifacts for the Web Service, packages everything into an archive file, and creates an Enterprise Application that you can then deploy to WebLogic Server.
By default, the jwsc Ant task packages the Web service in a standard Web application WAR file with all the standard WAR artifacts. The WAR file, however, contains additional artifacts to indicate that it is also a Web Service; these additional artifacts include deployment descriptor files, the WSDL file that describes the public contract of the Web Service, and so on. If you execute jwsc against more than one JWS file, you can choose whether jwsc packages the Web Services in a single WAR file or each Web Service in a separate WAR file. In either case, jwsc generates a single Enterprise Application.
If you implement a stateless session EJB in your JWS file, then the jwsc Ant task packages the Web Service in a standard EJB JAR file with all the usual artifacts, such as the ejb-jar.xml and weblogic-ejb.jar.xml deployment descriptor files. The EJB JAR file also contains additional Web Service-specific artifacts, as described in the preceding paragraph, to indicate that it is a Web Service. Similarly, you can choose whether multiple JWS files are packaged in a single or multiple EJB JAR files.
How Do I Choose Between JAX-WS and JAX-RPC?
As noted previously, this release of WebLogic Server supports the following Web Services:
Because JAX-WS is the successor to the JAX-RPC and it implements many of the new features in Java EE 5, Oracle recommends that you develop Web Services with JAX-WS. JAX-RPC is considered legacy and the specification is no longer evolving.
The following table summarizes the benefits of choosing JAX-WS over JAX-RPC. There may be reasons to continue developing JAX-RPC Web Services, which you can weigh against the benefits listed below.
JAX-WS Web Services do not support context propagation
Benefit Description SOAP 1.2 Support JAX-WS supports SOAP 1.2 and 1.1. JAX-RPC supports SOAP 1.1 only.
Data Binding Using JAXB 2.1 JAX-WS 2.1 fully supports the Java Architecture for XML Binding (JAXB) 2.1 specification and provides full XML Schema support. JAXB provides a convenient way to bind an XML schema to a representation in Java code. This makes it easy for you to incorporate XML data and processing functions in applications based on Java technology without having to know much about XML itself. By contrast, the built-in and user-defined data types you can use in a JAX-RPC-style Web Service, although extensive, is limited to those described in “Using JAXB Data Binding”
Document Attachments Using MTOM JAX-WS 2.1 supports Message Transmission and Optimization Mechanism (MTOM) which, together with XML Binary Optimized Packaging (XOP) defines how an XML binary data such as xs:base64Binary or xs:hexBinary can be optimally transmitted over the wire. In this release of WebLogic Server, MTOM is also supported for JAX-RPC 1.1 style Web Services.
Web Service Annotations JAX-WS 2.and JAX-RPC 1.1 both use metadata annotations (JSR 181) and then Ant tasks to compile the annotated Java file into a deployable enterprise application (EAR) file. However, the JAX-WS 2.1 programming model is more robust because it defines additional annotations, listed in the JAX-WS 2.1 specification, that you can use to customize the mapping from Java to XML schema/WSDL and to map Web Service operation parameter names to meaningful part/element names in the WSDL file. For a comparison of the Web Service annotation support for JAX-WS and JAX-RPC, see “Web Service Annotation Support” in WebLogic Web Services Reference. XML-based Customizations The JAX-WS 2.1 specification defines standard and portable XML-based customizations. These customizations, or binding declarations, can customize almost all WSDL components that can be mapped to Java, such as the service endpoint interface class, method name, parameter name, exception class, etc. Using binding declarations you can also control certain features, such as asynchrony, provider, wrapper style, and additional headers. Logical and Protocol Handlers JAX-WS 2.1 defines two types of handlers: logical and protocol handlers. While protocol handlers have access to an entire message such as a SOAP message, logical handlers deal only with the payload of a message and are independent of the protocol being used. Handler chains can now be configured on a per-port, per-protocol, or per-service basis. A new framework of context objects has been added to allow client code to share information easily with handlers. EJB 3.0 Support JAX-WS supports EJB 3.0. JAX-RPC supports EJB 2.1 only.
Roadmap for Implementing WebLogic Web Services
New and Changed Features in this Release
For a comprehensive listing of the new WebLogic Server Web Service features introduced in this release, see “Web Services” in “What's New in WebLogic Server” in Release Notes.