|Oracle® Fusion Middleware Getting Started With JAX-WS Web Services for Oracle WebLogic Server
12c Release 1 (12.1.1)
Part Number E24964-01
|PDF · Mobi · ePub|
This chapter provides an overview of developing WebLogic Web services using the Java API for XML-based Web services (JAX-WS). JAX-WS is a standards-based API for coding, assembling, and deploying Java Web services.
This chapter includes the following sections:
WebLogic Web services are implemented according to the JSR 109: Implementing Enterprise Web Services specification (
http://www.jcp.org/en/jsr/detail?id=109), 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 JSR 109: Implementing Enterprise Web Services specification (
http://www.jcp.org/en/jsr/detail?id=109) describes that a Java EE Web service is implemented by one of the following components:
A Java class running in the Web container.
A stateless or singleton session EJB running in the EJB container.
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 JDK 6.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 (
http://www.jcp.org/en/jsr/detail?id=181) as well as a set of other standard or WebLogic-specific annotations, depending on the type of Web service you are creating.
Once you have coded the basic WebLogic Web service, you can program and configure additional advanced features. For example, you can specify that the SOAP messages be digitally signed and encrypted (as specified by the WS-Security specification at
http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=wss). You configure these more advanced features of WebLogic Web services using WS-Policy files, which is an XML file that adheres to the WS-Policy specification and contains security-specific or Web service reliable messaging-specific XML elements that describe the security and reliable-messaging configuration, respectively.
There are two approaches to Web service development: bottom-up and top-down. Each approach is described in the following sections.
In the bottom-up approach, you develop your the JWS file from scratch. After you create the JWS file, you use the
jwsc WebLogic Web service Ant task to compile the JWS file, as described by the JSR 109: Implementing Enterprise Web Services specification at
jwsc Ant task always compiles the JWS file into a plain Java class; the only time it implements a stateless or singleton session EJB is if you implement a stateless or singleton 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 or singleton session EJB in your JWS file, then the
jwsc Ant task packages the Web service in a standard EJB JAR with all the usual artifacts, such as the
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.
Alternatively, you can specify that your session EJB be packaged as a Web application WAR file by updating the
jwsc Ant task in your
build.xml file to enable the
ejbWsInWar attribute in the
module child element. For more information, see "jwsc" in WebLogic Web Services Reference for Oracle WebLogic Server.
For more information about the bottom-up approach, see Developing WebLogic Web Services Starting From Java: Main Steps.
In the top-down approach, you create the Web service from a WSDL file. You can use the
wsdlc Ant task to generate a partial implementation of the Web service described by the WSDL file. The
wsdlc Ant task generates the JWS service endpoint interface (SEI), the stubbed-out JWS class file, JavaBeans that represent the XML Schema data types, and so on, into output directories.
After running the
wsdlc Ant task, (which typically you only do once) you update the generated JWS implementation file, for example, to add Java code to the methods so that they function as defined by your business requirements. The generated JWS implementation file does not initially contain any business logic because the
wsdlc Ant task does not know how you want your Web service to function, although it does know the shape of the Web service, based on the WSDL file.
wsdlc Ant task packages the JWS SEI and data binding artifacts together into a JAR file that you later specify to the
jwsc Ant task. You never need to update this JAR file; the only file you update is the JWS implementation class.
For more information about the top-down approach, see Developing WebLogic Web Services Starting From a WSDL File: Main Steps.
The following table provides a roadmap of common tasks for developing, packaging and deploying, invoking, and administering RESTful Web services and clients using WebLogic Server.
Table 1-1 Roadmap for Implementing JAX-WS Web Services
|This chapter . . .||Describes how to . . .|
Run common use cases and examples.
Develop Web services using the WebLogic development environment.
Program the JWS file that implements your Web service.
Use the Java Architecture for XML Binding (JAXB) data binding.
Invoke your Web service from a stand-alone client or another Web service.
Administer WebLogic Web services using the Administration Console.
Migrate a JAX-RPC Web service to JAX-WS.
The JAX-WS implementation in Oracle WebLogic Server is extended from the JAX-WS Reference Implementation (RI) developed by the Glassfish Community (see
http://jax-ws.java.net/). All features defined in the JAX-WS specification (JSR-224) are fully supported by Oracle WebLogic Server.
The JAX-WS RI also contains a variety of extensions, provided by Glassfish contributors. Unless specifically documented, JAX-WS RI extensions are not supported for use in Oracle WebLogic Server.
For an overview of WebLogic Web services, standards, samples, and related documentation, see Introducing WebLogic Web Services for Oracle WebLogic Server. For information about WebLogic Web service security, see Securing WebLogic Web Services for Oracle WebLogic Server.