D59163GC10 sg1
D59163GC10 sg1
D59163GC10
Edition 1.0
October 2009
D63214
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Authors Copyright © 2009, Oracle. All rights reserved.
Iris Li Disclaimer
Al Saganich This document contains proprietary information and is protected by copyright and other intellectual
property laws. You may copy and print this document solely for your own use in an Oracle training
Technical Contributors course. The document may not be modified or altered in any way. Except where your use constitutes
"fair use" under copyright law, you may not use, share, download, upload, copy, print, display,
and Reviewers perform, reproduce, publish, license, post, transmit, or distribute this document in whole or in part
without the express authorization of Oracle.
Pyounguk Cho
Steve Friedberg The information contained in this document is subject to change without notice. If you find any
problems in the document, please report them in writing to: Oracle University, 500 Oracle Parkway,
Joe Greenwald Redwood Shores, California 94065 USA. This document is not warranted to be error-free.
Vasiliy Strelnikov
Restricted Rights Notice
Holger Rasmussen
If this documentation is delivered to the United States Government or anyone using the
documentation on behalf of the United States Government, the following notice is applicable:
Publisher Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be
trademarks of their respective owners.
Pavithran Adka
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Contents
iii
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Summary 1-28
Practice 1 Overview: Reviewing Terms and Concepts 1-29
Describing the Course Environment 1-30
Configuring a Grid VM Connection 1-31
Configuring a Grid VM Connection: Session 1-32
Configuring a Grid VM Connection: Desktop 1-33
Configuring a Grid VM Connection: Configuration Completed 1-34
Connecting to the Grid VM Instance 1-35
iv
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
XML Namespace and XML Schema 3-5
SOAP: XML Messaging for Web Services 3-7
Communication with SOAP 3-8
SOAP over HTTP 3-9
Basic Structure of SOAP 3-10
SOAP Messages: Example 3-12
Examining SOAP Messages Using the HTTP Analyzer 3-13
SOAP Message Formats 3-14
Quiz 3-16
RPC-Style SOAP Message Structure 3-17
v
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
JSR 181 Annotations 4-12
Complex Return Results 4-13
Web Service Life Cycle 4-14
PostConstruct and PreDestroy Life Cycle Annotations 4-15
An Example of POJO-Based Service Endpoint 4-17
Quiz 4-19
Implementing Web Services Using EJB 4-20
An Example of EJB Endpoint 4-21
The Provider API: Working with XML Directly 4-22
A Sample of Provider Endpoint 4-23
vi
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Dispatch Client Support Matrix 5-26
A Sample of Dispatch Client 5-27
Invoking a Web Service Using the Dispatch API 5-28
Agenda 5-29
JAX-WS Web Services Invocation Mechanisms: Synchronous 5-30
JAX-WS Web Services Invocation Mechanisms: Asynchronous 5-31
Asynchronous Invocation Models 5-32
HelloWorld (SEI) with Asynchronous Method Calls 5-33
HelloWorldPortClient: Asynchronous Polling 5-35
Asynchronous Callback: Sequence Diagram 5-36
vii
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Deploying Web Services Using OEPE 6-23
Deploying a Web Service with a SIB 6-24
Steps for Deploying a Web Service with an SIB and WSDL 6-25
Using jwsc Ant to Package Web Services 6-26
Updating the build.xml File for the jwsc Ant Task 6-27
Using the wldeploy Ant Task to Deploy Web Services 6-28
Overview of WebLogic Web Services Administration Tasks 6-29
Basics of WebLogic Server Administration Console 6-31
Managing Web Services by Using the Administration Console 6-33
Web Service Configuration 6-34
viii
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Implicit Fault Example on the Server Side 7-27
Implicit Fault Example on the Client Side 7-28
Exceptions in the Log File 7-29
Quiz 7-30
Summary 7-31
Practice 7 Overview: Handling Web Service Exceptions 7-32
ix
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Quiz 8-38
Invoking a Message-Secured Web Service 8-39
Sample Client Code 8-40
Invoking a Web Service from Within a WebLogic Server Instance 8-42
Oracle WSM WS-Security Policies 8-44
Adding Oracle WSM WS-Security Policies to a Web Service 8-45
Nonsupported Oracle WSM WS-Security Policies 8-46
Summary 8-47
Practice 8 Overview: Securing Web Services Using WS-Policy 8-48
x
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Adding Client-Side Handlers 9-38
Summary 9-39
Practice 9 Overview: Creating Handlers for Web Services 9-40
xi
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Type Mapping Mechanisms 11-5
JAXB Binding Scenarios 11-6
Quiz 11-7
Binding XML Schema to Java Representation 11-8
Example of XML Schema-to-Java Mapping 11-9
Mapping Java Types to XML Schema 11-10
Data Type Mapping 11-11
Built-in Data Types: XML-to-Java Mapping 11-12
Built-in Data Types: Java-to-XML Mapping 11-13
Supported User-Defined XML Schema Data Types 11-14
xii
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Creating a Web Service Using Annotations 12-10
Creating a JAX-RPC Web Service Using JDeveloper 12-11
Quiz 12-12
JAX-RPC Client-Side Programming Models 12-13
Invoking Web Services Using a Generated Stubs Model 12-14
Endpoint Interface Generated from WSDL 12-15
Generated Stub Class 12-16
Generated Service Interface and Implementation 12-17
Using the Stub Interface to Access Run-Time Information 12-18
WebLogic Web Services Stub Properties 12-19
xiii
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Configuring Destination WebLogic Server Instance 13-25
Configuring JMS and SAF Resources Using Configuration Wizard 13-27
Configuring Source WebLogic Server Instance 13-28
Quiz 13-29
Annotations for Reliable Messaging 13-30
Sample RM Web Service 13-32
Invoking a Reliable Web Service 13-34
Reliable Web Service Client 13-35
Web Service Client 13-36
Quiz 13-37
xiv
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Quiz 15-9
Developing Web Services That Expose Database Resources 15-10
Exposing PL/SQL Packages as Web Services 15-12
Steps for Exposing PL/SQL Packages as Web Services by Using JDeveloper 15-13
Creating a Database Connection 15-14
Examining the PL/SQL Package 15-15
Publishing the PL/SQL Package as a Web Service 15-16
Generated Web Service’s Artifacts 15-19
Creating the Application Deployment Profile 15-20
Testing the Generated Web Service by Usingthe Administration Console 15-21
xv
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Introducing Orchestration 17-9
Introducing Business Process Execution Language (BPEL) 17-10
Introducing SCA in Oracle SOA Suite 11g 17-11
Service Component Architecture (SCA) 17-12
Elements of SCA 17-13
Service Data Object (SDO) 17-14
Designing with an SOA Approach 17-15
Types of Service Access and Implementation 17-16
Implementing SOA: General Concepts 17-17
Oracle SOA Suite 11g Components 17-18
Glossary
xvi
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web
Services
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Audience
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services I - 2
Class Introductions
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services I - 3
Goal
The main goal of this course is to use the Java Web Services
API to develop interoperable Web Services.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services I - 4
Course Objectives
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services I - 5
Course Objectives
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services I - 6
Prerequisites
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services I - 7
Course Map
Building SOA
Best Practices
with Web Services
Course Map
The course map shows all the lessons of this course and how they are grouped into sections.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services I - 8
Course Environment
ORACLE
JDeveloper 11g
JDeveloper
provides the Java development environment.
Oracle Database Express 10g (10.2.0.1.0)
provides the database environment.
Course Environment
In this course, the following products are used for the lesson practices:
• Oracle Enterprise Linux 5
• Oracle WebLogic Server 11g R1 (10.3.1.0)
• Oracle Database XE 10.2.0.1.0
• JDeveloper 11.1.1.1.0
• Eclipse with OEPE (3.4.2 and OEPE 11.1.1.1.0)
• Java JDK 1.6.0_13
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services I - 9
Course Schedule
Session Module
I: Course Introduction
A.M. 1: Introducing Web Services
Day
2: Java Web Services Technologies Overview
1
3: Exploring SOAP and WSDL
P.M.
Course Schedule
The class schedule might vary according to the pace of the class. The instructor will provide
updates.
At the end of the course, the instructor facilitates a feedback session that includes a written
questionnaire.
Oracle University uses your feedback to improve our training programs. We appreciate your
honest evaluation.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services I - 10
Course Schedule
Session Module
9: Using Handlers in JAX-WS Web Services
A.M. 10: Optimizing Binary Data Transmission Using
Day
MTOM/XOP
3
11: JAX-WS Binding Customization
P.M.
12: Implementing JAX-RPC Web Services
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services I - 11
How Can I Learn More?
Topic Website
Education and Training http://education.oracle.com
Product Documentation http://www.oracle.com/technology/documentation
Product Downloads http://www.oracle.com/technology/software
Product Articles http://www.oracle.com/technology/pub/articles
Product Support http://www.oracle.com/support
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services I - 12
Introducing Web Services
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Objectives
Objectives
This lesson presents a brief architectural overview of Web services.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 1 - 2
The Drive Towards Web Services
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 1 - 3
The Drive Towards Web Services (continued)
The basic prerequisite for all IT is that the applications ought to reflect the changing needs of
business—specifically, the need for changing a business process from one version to another.
This requirement has been the main driver for SOA. Web services have been around for at least
10 years as a platform-independent distributed component attempting to solve business
functions. Later, it has been shown that it could be used as a non-proprietary integration
component. As seen from a SOA perspective, which is of highest importance, integration ability
is just a nice side effect, but not the key driver, of implementing a SOA infrastructure.
Furthermore, HTTP as the primary transport protocol, in spite of the performance penalties, is
also a key driver towards Web Services because of its ease of use in most networks.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 1 - 4
What Web Services Are
Web services:
• Provide a simple and interoperable messaging framework
• Are easily accessible from heterogeneous environments
because they are:
– Loosely coupled
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 1 - 5
What Web Services Are (continued)
Web services provide a distributed computing technology using standard XML protocols and
formats. Because a Web service uses standard protocols for communication and data transfer, it
is platform and implementation independent. You interact with a Web service in a standard way,
independently of the technology—such as the underlying protocols, component models,
programming language, or operating system—used to implement the service.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 1 - 6
The Integration Problem
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 1 - 7
Web Services Versus Web Applications
• User-to-program Program-to-program
interaction interaction
Static integration of Dynamic integration
components of components
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 1 - 8
The Building Blocks of Web Services
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 1 - 9
SOAP
SOAP
Using SOAP as a message exchange format is the most agreed-upon piece of the Web services
architectures. Some basic facts about SOAP:
• SOAP is just another XML markup language accompanied by rules that dictate its use.
SOAP defines an XML-based structure for passing information, such as messages and data,
between a Web service and a service client.
• The purpose of SOAP is to exchange data over network. Specifically, it concerns itself
with encapsulating XML data and defining the rules for transmitting and receiving that
data.
• A SOAP message is a SOAP XML document instance, which is designed to be embedded
inside other network protocols. SOAP only defines the structure of the payload of XML
messages as they are transported over the wire. The most common network protocol of
sending and receiving SOAP messages is via HTTP. Other network protocols that can
carry SOAP messages include Simple Mail Transfer Protocol (SMTP), FTP, JMS, e-mail,
and so on.
Note: This lesson just provides an introduction of SOAP standard, the structure of SOAP
messages and processing rules are discussed in Lesson 3 – Exploring SOAP and WSDL.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 1 - 10
WSDL
WSDL
Web Services Description Language or WSDL:
• Is at version 2.0 and is a W3C recommendation
• Is currently supported at level 1.2 in WebLogic Server
• Is an XML-based format to describe the message format, network protocol, and address
that a client uses to communicate with a particular Web service
• Adheres to the WSDL XML schema and must be well formed
• Can be used by clients to locate a service and invoke public functions
For each Web service, the service provider should create a WSDL file that describes it (most
commonly these are generated rather than hand coded). The WSDL file is then available to
potential clients through a variety of mechanisms including registration with a service broker.
The WSDL file used by the client to understand the syntax for communication with the Web
service can be retrieved from third parties such as a service broker or from the service provider
itself.
Armed with a WSDL document describing a service, developers can implement clients or
services with confidence that their implementations will work successfully.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 1 - 11
UDDI
Provides the where and how
UDDI
Universal Description, Discovery and Integration, or UDDI, is a data model by which Web
services and the businesses that support them can be published, discovered, and used. UDDI is
currently at version 3.0. UDDI is described in a set of specifications that separately cover the
programmer’s API, common data structures, administrative issues, and other related topics.
UDDI identifies the registry as the standard component for publishing to and querying
repositories of information about businesses, common models for data and behavior, and Web
services.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 1 - 12
Quiz
Answer: 4
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 1 - 13
Web Services Interaction
Service
registrar
(UDDI)
2 3 1
Look up Retrieve the service Publish
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 1 - 15
WS-I Basic Profile
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 1 - 16
WS - * Specifications
WS-SecurityPolicy
WS-Security
WS-SecureConveration
WS-* Specifications
SOAP, WSDL and UDDI, are standards at the core of Web services, and they are followed by
many additional specifications that define reliability, security, metadata management,
transactions, and orchestration to meet requirements for enterprise features and qualities of
service. These specifications are generally referred to as WS-*. The diagram above shows a
variety of specifications categorized in three main groups, and they will be discussed in this
course later on.
Messaging
• Message Transmission Optimization Mechanism (MTOM): Is used for optimizing the
wire format of SOAP messages
• WS-Addressing: Supports normalized Web service addresses, enabling multiple transports
to be used (besides HTTP)
• WS-ReliableMessaging: Enables Web services running on different servers to
communicate reliably in the presence of failures in software components, systems, or
networks exchanges
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 1 - 17
WS-* Specifications (continued)
Metadata Exchange
• WSDL: Base service and message description
• WS-Policy: Policies express and handle requirements and capabilities of Web service
consumers and providers.
• WS-MetadataExchange: A protocol to enable a consumer to obtain a service’s metadata
(its WSDL and policies). Think of it as a bootstrap mechanism for communication.
• UDDI: Provides information about where the Web services are and how to access them
Security
• WS-SecurityPolicy: Defines specific policies (assertions) that describe how messages are
secured
• WS-Security: Provides message content integrity and confidentiality
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 1 - 18
Web Services Architectural Styles
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 1 - 19
RESTful Versus SOAP-Based Web Services
Often used by AJAX applications
REST SOAP
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 1 - 20
Quiz
Answer: 2
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 1 - 21
Definition: Service-Oriented Architecture (SOA)
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 1 - 22
SOA Further Defined
Client
Service
Service
WSDL
Service
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 1 - 24
Standards That Enable SOA
Current and Emerging Standards Category
Business
Orchestration: BPEL4WS
processes
WSDL Description
SOAP
Message
XML
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 1 - 25
Web Services and SOA
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 1 - 26
Web Services and SOA (continued)
There are a number of reasons to not consider Web Services in SOA as well, for example:
• Real time system Performance: Web Services are typically too slow for R/T systems.
• Large payloads: Direct datasource to datasource should be considered for very large
payloads, rather then subject the application to network latency to send large document
transfers.
• Choose JMS for better performance: Message driven middleware, where messages need
to be handled sequentially etc may be a better choice for some implementations.
• Transactional challenges: Web Services do not support call correlation or long running
transactions.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 1 - 27
Summary
Summary
This slide summarizes what you have learned in this lesson.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 1 - 28
Practice 1 Overview:
Reviewing Terms and Concepts
This practice covers the following topics:
• Reviewing Web Service terms and definitions
• Connecting to your assigned Grid VM machine
• Exploring the development environment
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 1 - 29
Describing the Course Environment
Grid VM
Server
Classroom PC Linux Virtual
Machine
Oracle WebLogic
JDeveloper Server
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 1 - 30
Configuring a Grid VM Connection
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 1 - 31
Configuring a Grid VM Connection: Session
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 1 - 32
Configuring a Grid VM Connection: Desktop
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 1 - 33
Configuring a Grid VM Connection: Configuration
Completed
5
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 1 - 34
Connecting to the Grid VM Instance
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 1 - 35
Oracle University and Egabi Solutions use only
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Java Web Services Technologies Overview
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Objectives
Objectives
This lesson presents a high-level overview of Java Web Services APIs. It intends to provide an
appreciation for the big picture and sets the stage to go into the programming details in subsequent
lessons.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 2 - 2
Java Technology for Web Services
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 2 - 3
Java Web Services
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 2 - 4
Java Web Services Standards
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 2 - 5
JAX-WS Programming Model
Client Service
Service Endpoint
Implementation
(SEI)
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 2 - 6
JAX-WS Benefits
JAX-WS Benefits
JAX-WS is the next generation Web services programming model to extend the foundation provided
by the JAX-RPC programming model. JAX-WS offers the following benefits:
• Using the JAX-WS programming model, development of Web services and clients is simplified
through support of a standards-based annotations model. The JAX-WS standard supports the
use of annotations that are based on several JSRs: JSR 181, JSR 224, JSR 222 and Common
Annotations for the Java Platform [JSR 250]. Annotations used in JAX-WS will be covered
later in this course.
• JAX-WS represents remote procedure calls or messages using XML-based protocols such as
SOAP, but hides SOAP’s complexity behind a Java API by using standard Java/WSDL
mapping. When a SOAP message invokes a WSDL described operation, the Java/WSDL
mapping decides which Java method gets invoked and how that SOAP message is mapped to
the method’s parameters. Conversely, the mapping also determines how the method’s return
value gets mapped to the SOAP response.
• Improve messaging support, including asynchronous operations and transports besides HTTP,
and improve schema support by using JAXB data binding as the replacement of JAX-RPC
1.X’s simple built-in binding. JAX-WS and JAXB technologies are well integrated. When
starting from Java classes, JAXB can generate XML Schema documents that are automatically
embedded inside a WSDL document, saving users from performing this time-consuming and
error-prone integration manually.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 2 - 7
WS-Metadata Benefits
WS-Metadata Benefits
Annotations are at the center of the ease-of-use features of Java EE 5. WS-Metadata [JSR181]
defines the standard annotations that are used to develop and deploy Web Services within a Java EE
5 container. Using annotations, developers can create portable JWS from a simple Plain Old Java
Object (POJO) class.
You can annotate types, methods, fields, and parameters in your Java class to specify a Web service.
The developer can take advantage of the annotations to specify how a Web Service should be
exposed to the outside world as the annotation development model provides fine-grained control over
exposing the Web Services. For example, if you want only to expose certain business operations in
the Java class, you may find @WebMethod annotation useful.
WS-Metadata can be used to shape the deployment of a Web service. Web service developers define
only the annotated Java Web service file and leave the job of creating necessary deployment and
configuration files to the vendor. With annotations, you usually do not need deployment descriptors
when deploying a Web service.
Note: JSR181 also defines other annotations, such as configuring bindings and handler chains,
setting WSDL parameters, and so on. They will be discussed in the subsequence lessons.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 2 - 8
A Simple Annotated Java Class
import javax.jws.WebService;
import javax.jws.WebMethod;
@WebService Required
public class AddNumbersServiceImpl {
@WebMethod Optional
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 2 - 9
Java Web Service from POJO Rules
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 2 - 10
Quiz
Answer: 2
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 2 - 11
JAXB
JAXB
Both Java and XML Schema are complex and expressive languages. Implementing a standard
binding between these languages is a large, complex task. In JAX-WS 2.0, all data binding has been
delegated to JAXB 2.0 which provides a higher level of abstraction than Java implementations of
SAX, DOM, and XPath to make it easier for Java programmers to work with XML instances of the
schema.
Binding two scenarios:
• Start from Java: JAXB implementations provide a schema generator that creates schema from
existing classes using the standard map. The classes need not be explicitly annotated, because
JAXB 2.0 defines defaults to supply implied annotations wherever needed.
• Start from XML Schema: JAXB 2.0 implementations provide a schema compiler that
generates Java classes from an XML schema.
• JAXB 2.0 uses mapping annotations for customizing standard Java/XML binding. When a class
has no annotations, the XML schema generated by schema generator is based entirely on the
default Java/XML binding. If mapping annotations are provided, the Java class maps to a
unique XML Schema component based on its annotations. This topic will be discussed in depth
later in this course.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 2 - 12
SOAP with Attachments API for Java (SAAJ)
• SAAJ:
– Provides Java APIs to read, write, send, and receive SOAP
messages
– Allows binary content to be attached to a SOAP message
• The SAAJ 1.3 APIs conform to the SOAP 1.1 and 1.2
specifications and the SOAP with Attachments (SwA)
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 2 - 13
WSEE
WSEE
WSEE (JSR-109) is to promote the building of interoperable and portable Web services in the Java
EE environment. WSEE has been around since J2EE 1.4. WSEE 1.2 is the release that works with
JAX-WS 2.0. Some basics about WSEE 1.2 include:
• WS-Metadata describes how annotations on the packaged classes shape the deployment, while
WSEE 1.2 defines the deployment process and the packaging structure. For example, it
specifies that a POJO can be deployed to the Web container, and a stateless session bean can be
deployed to the EJB container.
• Web services deployment using WSEE 1.0. is quite complicated in J2EE 1.4. This deployment
complexity has been greatly reduced through the use of annotations, together with the
simplified architecture and packaging as defined in WSEE 1.2. In the new programming model,
service implementation bean (SIB) is the only required artifact for deployment. Many artifacts
required by J2EE 1.4, such as Web services deployment descriptors and SEI, are optional.
Note: WS-Metadata defines the requirements for deploying a Java class as a Web service.
Classes that meet these requirements are called service implementation beans (SIBs).
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 2 - 14
Roles of APIs in Web Services Invocation
XML Java
parameters parameters
1
WSDL
7 6
POJOs
SOAP 5
JAX-WS
JAXB
JAX-WS JAXB
WS-Metadata
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 2 - 15
Roles of APIs in Web Services Invocation (continued)
5. Once the parameters have been created, the JAX-WS run time invokes the target Java
class/method. The class providing the method for invocation can be either an Enterprise
JavaBeans bean (EJB) or a Plain Old Java object (POJO). Annotations from JAX-WS, JAXB,
and WS-Metadata are all used in these Java classes that comprise the Web service application.
6. After the invocation, Java return type class is handed off for JAXB serialization to become an
XML return type instance. This serialization is controlled by the annotations on the Java return
class.
7. Then, the JAX-WS run time takes the XML return type instance and wraps it in a SOAP
response.
Finally, the SOAP response is sent back to the requester as the payload of the HTTP response.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 2 - 16
JAX-RPC and JAX-WS Stack Comparison
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 2 - 17
Java Web Service Development Approaches
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 2 - 18
Bottom-Up Approach
Generate WSDL 2
WSDL 1 Generate Java
artifacts artifacts
Web service
POJO client
Bottom-Up Approach
Web Service Development
1. The business logic is provided using either Java classes or EJBs and contain methods that are
exposed in the Web service interface.
2. A Web service generation tool (in this case, Java-to-WSDL) generates the WSDL. The Web
service generation tool can be the JDeveloper, OEPE, or an Ant task.
Web Service Client Development
1. The Web service generation tool (in this case, WSDL-to-Java) generates the client-side
proxy class and other client-side artifacts from WSDL.
2. The Web service client application uses the proxy class to communicate with the Web service
application.
Note: With the bottom-up approach, the development of the Web service client is dependent on the
implementation of the Web service because the entire client-side artifacts (such as the proxy) are
developed from the WSDL document.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 2 - 19
Top-Down Approach
XSD schemas
1 1
Top-Down Approach
Web Service Development
1. A WSDL document is created. You can incorporate multiple XSD schemas in the WSDL
document, which describes the input and the output data types for the Web service operation.
2. The Web service generation tool (in this case, wsdlc) generates the Java artifacts, such as the
service endpoint interface, which are implemented as a Web service.
Web Service Client Development
1. Similar to that of the Web service development.
2. The Web service generation tool (in this case, clientgen) generates the Java artifacts, such
as the client-side proxy, which are used by the client application to communicate with the Web
service.
Note: In the top-down approach, the development of the client-side and the server-side can be done
in parallel, and without any dependency on each other.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 2 - 20
WebLogic Server Support for JWS
• WS-Policy 1.5
• WS-SecurityPolicy 1.2
• Asynchronous request-response
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 2 - 21
Quiz
Answer: 2
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 2 - 22
Web Service Development Process
MyService.java
Create SEI
(w/ annotation)
Build javac
war/ear
Deploy
Application
Server
Test
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 2 - 23
Tools for JWS Development
JDeveloper MyService.java
Create SEI
OEPE (w/ annotation)
JDeveloper
OEPE Build javac
Ant task web.xml
or
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 2 - 24
Creating Web Services by Using
Oracle JDeveloper 11g
Resources Palette
pane
Application
Structure
pane
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 2 - 25
Creating Web Services by Using Oracle JDeveloper 11g (continued)
JDeveloper 11g is shipped with WebLogic server 10.3.1. You can directly deploy a Web service
application from JDeveloper to WLS.
In addition, JDeveloper 11g provides a complete Web services test framework, and a comprehensive
WSDL editor. There are also many developer productivity enhancements to the IDE and Java
development features to explore.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 2 - 26
Creating a Web Service from a Java Class by
Using JDeveloper
To create a simple Web service from a Java class by using
JDeveloper:
1. Create a Java class.
2. Add the @WebService annotation to the Java class.
3. Build the project—compile and generate artifacts.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 2 - 27
Summary
Summary
This slide summarizes what you have learned in this lesson.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 2 - 28
Practice 2 Overview:
Developing a Simple Web Service
This practice covers the following topics:
• Creating a JDeveloper Project
• Creating an annotation-based Web Service
• Deploying an application into WebLogic Server from
JDeveloper
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 2 - 29
Oracle University and Egabi Solutions use only
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Exploring SOAP and WSDL
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Objectives
Objectives
SOAP and WSDL are the core of Web services. This lesson is intended to provide a conceptual
understanding of these two fundamental WS standards.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 3 - 2
Basics of XML
Basics of XML
XML is an extensible, non-proprietary, text-based markup language that has become the de facto
standard for data interchange on the Internet and within distributed applications and web services.
• An XML markup language defines a set of tags that are used to organize and describe data.
• XML is self-describing as XML organizes data into a hierarchy, and it describes its
organization directly in the text, so you do not need to look at a separate document that
describes the organization of the data.
• XML allows the author to define their own tags and their own document structure. So you can
extend XML almost limitlessly, defining markup and rules as needed for the kinds of data and
information you use.
• XML uses DTD to define the rules that specify the elements, element formats, and attributes
that are valid in a document instance, as well as the rules defining the relationships between
those elements. The DTD provides a basic grammar for defining an XML document in terms of
the metadata that comprise the shape of the document. An XML Schema provides this, plus a
detailed way to define what the data can and cannot contain.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 3 - 3
Basics of XML (continued)
• XML implementations can be divided into two general categories: document-centric and data-
centric:
- Document-centric XML refers to documents intended for human consumption, but which
can still be processed programmatically, and are based on structured or semi-structured
markup. Examples include technical documentation, product catalogs and legal
documents.
- Data-centric XML refers to highly structured XML files intended for machine
consumption rather than human readability. Examples of this kind of XML include
programmatic structures, and data from relational databases.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 3 - 4
XML Namespace and XML Schema
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 3 - 5
XML Namespace and XML Schema (continued)
XML Schema
An XML schema is an XML document that defines the syntax of XML documents governed by the
schema. Because all XML schema must follow the rules set out in the primal XML schema, they can
be validated against that schema. It is important for maintaining data quality and integrity when
sharing information among multiple systems. Data types in schemas have two general forms: Simple
and Complex. Simple is a terminal element; complex contains a sequence of child elements.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 3 - 6
SOAP: XML Messaging for Web Services
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 3 - 7
Communication with SOAP
Response Server
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 3 - 8
SOAP over HTTP
Request
Response
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 3 - 9
Basic Structure of SOAP
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 3 - 10
Basic Structure of SOAP (continued)
• SOAP body: The body element is a mandatory element that contains information for the
recipient of the message.
• SOAP fault: The body element can contain an optional fault element to report errors.
A SOAP application should include proper SOAP namespaces on all elements defined in messages.
SOAP messages should not contain Document Type Declaration (DTD) and Processing Instructions
(PI).
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 3 - 11
SOAP Messages: Example
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/ SOAP
envelope/" namespace
Xmlns:ns="http://mypackage/">
Request
Application
<soap:Body>
<ns:add> namespace
<num1>1</num1> SOAP
<num2>1.1f</num2> Operation
</ns:add> (RPC style)
<soap:Envelope ...
xmlns:ns="http://mypackage/">
Response
<soap:Body>
<ns:addResponse>
<result>2.1</result>
</ns:addResponse>
</soap:Body>
</soap:Envelope>
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 3 - 12
Examining SOAP Messages
Using the HTTP Analyzer
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 3 - 13
SOAP Message Formats
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 3 - 14
SOAP Message Formats (continued)
The SOAP envelope, header, and body offer a lot of flexibility in expressing message information.
However, for general purposes in SOAP messaging there is a need for commonly understood
encoding rules that address questions of data representation to assure that a message recipient will
correctly interpret the data contained in a service request. RPC-style services, in particular, require
strict set of encoding rules.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 3 - 15
Quiz
Answer: 3
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 3 - 16
RPC-Style SOAP Message Structure
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 3 - 17
RPC-Style SOAP Message Structure (continued)
RPC/literal
RPC/literal messages are like RPC/encoded messages, except that the type encoding information is
eliminated. The RPC/literal format uses the RPC style of message payload structure but supports a
literal way of describing the types passed by a method. It means there exists a schema for every
parameter type but not for the payload of the message body itself. RPC/literal messages are WS-I
compliant.
The drawback of RPC-Style messages is they cannot be easily validated. Because the data typed are
defined in a schema/schemas, but the rest of the soap:body contents comes from WSDL definitions.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 3 - 18
Document-Style SOAP Message Structure:
document/literal
document/literal
<soap:Envelope ... >
<soap:Header>
<bElement>3.0</bElement>
</soap:Header>
<soap:Body ... >
<aElement>3</aElement>
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 3 - 19
Document-Style SOAP Message Structure:
document/wrapped
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 3 - 20
SOAP Attachment
Header
Body
Primary MIME Part
SOAP attachment
Graphic
SOAP attachment
SOAP Attachment
A SOAP message can include documents and file types that are otherwise difficult or inefficient to
encode as XML, such as graphics or database files, as SOAP attachments. SOAP attachments are
treated as secondary components of a SOAP message that are referenced by using a URI.
Diagram above illustrates the structure of a SOAP message that includes attachments. Using
attachments, certain information sets can travel along with the SOAP envelope, as MIME-type
attachments, rather than embedded in the SOAP body as XML. This is a useful feature especially
when passing medium to large quantities of binary-encoded information, such as images and sound
waves and other digitally sampled data.
The Web Services community have adopted SOAP Messages with Attachments (SwA) specification
to provides a mechanism to attach binary data to a SOAP message without converting binary data to
ASCII characters using Base64 encoding.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 3 - 21
WSDL
Bindings
Services
WSDL
SOAP provides a standard way of transporting messages for use by Web services, whereas WSDL
provides a standard way to describe Web services. WSDL uses the XML format for describing Web
services. It describes what functionality a Web service offers, how it communicates, and where it is
accessible. Because WSDL is in the standard XML format, the services developed can easily be
made available to thousands of users. Users must invoke the correct services with the appropriate
parameters. WSDL defines an XML grammar to specify the location of the service and to describe
the operations of a service.
A WSDL document describes a Web service by using these major elements:
• <types>: Defines the data types used by the Web service
• <message>: Describes the payload of a message used by a Web service
• <portType>: Describes a Web service, the operations that can be performed, and the messages
that are involved
• <binding>: Defines the communication protocols used by the Web service
• <service>: Describes the name and location of the Web service and the context with which it
can be accessed
Note that types, message and portType are abstract types which are then used in bindings and
services in much the same way an instance of a java class represents a java class.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 3 - 22
WSDL Model
XML Elements
Definition
attributes
targetNamespace
Input
message
Address
Element
Output location
name message
type
What How Where
Abstract Concrete
WSDL Model
The slide shows a structural model of the WSDL specification. The most important parts are:
• Element: Elements are defined with in the <types> tag. An element consists of a unique name,
and data type. An element describes the data and defines the tag which delimits the data sent in
the message parameters. Elements can be simple types such as strings or integers. Simple Types
can have enumerations (lists of acceptable values) or restrictions defined (length not to exceed
10 characters). In addition, elements can have complex types. Complex types can nest other
elements with in them.
• Message: The message describes the structure of the information that will be sent and received
when calling an operation. Each message consist of one or more logical parts. Each part is
associated with a message-typing attribute, usually a previously defined element.
• Operation: Each operation can be compared to a method or function call in a traditional
programming language. Here the SOAP actions are defined and the way the message is
encoded for example, “literal.”
• Port Type: The port type defines a web service, the operations that can be performed, and the
messages that are used to perform the operation.
• Binding: Specifies the port type, defines the SOAP binding style (RPC/Document) and
transport (SOAP Protocol). The binding section also defines the operations.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 3 - 23
WSDL Model (continued)
• Port: The port does nothing more than define the address or connection point to a web service.
This typically is a represented by a simple HTTP URL string.
• Service: The service can be thought of as a container for a set of system functions that have
been exposed to the web based protocols.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 3 - 24
A Basic WSDL Document
<?xml version='1.0'?>
2 <definitions targetNamespace=“urn:Math”
xmlns=“http://schemas.xmlsoap.org/wsdl/”
xmlns:sxd=“http://www.w3.org/2001/XMLSchema”
xmlns:soap=“http://schemas.xmlsoap.org/wsdl/soap/”>
7 <types/>
8 <message name='MathRequest'>
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 3 - 25
A Basic WSDL Document
16 <portType name='Math'>
17 <operation name='Add' parameterOrder='x y'>
18 <input message='tns:MathRequest'/>
19 <output message='tns:MathResponse'/>
20 </operation>
21 ...
22 </portType>
23
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 3 - 26
Defining the Structure of Content in the SOAP
Body
The structure of the content of the SOAP body is defined by
XML schema type definitions:
• Declared explicitly in WSDL
• Imported from an XML Schema Definition (XSD), as the
preferred approach for document/literal encoding
style
<import...>
Shared
<message name="helloReqest">
Other WSDL <part ... element="ns:hellostr"/>
services </message>
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 3 - 27
WSDL Binding
WSDL Binding
The binding element, and its subelements, are used in combination with protocol-specific elements.
The binding elements identify which portType and operation elements are being bound, while the
protocol-specific elements declare the protocol and encoding style to be associated with the
portType.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 3 - 28
WSDL Styles
WSDL Styles
There four styles of WSDL definitions, specifically:
• RPC/Encoded: In RPC/Encoded the method names, and parameters are defined in the WSDL.
But the SOAP message itself has typing information. For example a type=e “xsd:xxx” attribute
is provided for each parameter. This bloats the SOAP message and often makes the WSDL not
WS-I compliant. For the most part RPC/Encoded is ignored in favor of RPC/literal.
• RPC/Literal: In RPC/Literal the method and parameters in the WSDL are effectively the same
as those in RPC/encoded however the SOAP messages themselves do not contain typing
information. One of the strengths of RPC/Literal is its compliance with the WS-I basic profile.
One of the weaknesses of RPC/Literal is that the message cannot be validated based on the
SOAP content itself.
• Document/encoded: Document/encoded exists for historical purposes and should not be used
unless you are require backward compatibility.
• Document/literal: In Document/literal the WSDL defines the methods and parameters, but the
SOAP message does not contain method information, just parameter information. Because of
the extensive typing in the WSDL Document/literal can be validated.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 3 - 29
RPC/literal Message WSDL
<message name="addRequest">
<part name="a" type="xsd:int"/>
<part name="b" type="xsd:float"/>
</message>
<message name="empty"/>
<portType name="Math">
WSDL <operation name="add">
<input message="addRequest"/>
<output message="empty"/>
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 3 - 30
document/literal Message WSDL
<types>
<schema>
WSDL <element name="aElement" type="int"/>
<element name="bElement" type="float"/>
</schema>
</types>
<message name="addRequest">
<part name="param1" element="aElement"/>
<part name="param2" element="bElement"/>
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 3 - 32
document/literal Message WSDL (continued)
<binding name="docLiteralSoapHttp" type="docLiteral">
<soap:binding style="document" ... />
<operation name="add">
<soap:operation soapAction="http://literal2//add"/>
<input>
<soap:header message="addRequest" part="param2"
use="literal"/>
<soap:body use="literal" parts="param1"/>
</input>
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 3 - 33
document/wrapped Message WSDL
<types>
<schema>
WSDL
<complexType name="add"> ...
<element name="aElement" type="xsd:int"/>
<element name="bElement" type="xsd:float"/>
...
</complexType> ...
<element name="addElement" type="add"/> ...
</types>
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 3 - 34
An Example with SOAP Binding
<service name="MathService">
<port name="Math" binding="tns:MathBinding">
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 3 - 35
Quiz
Answer: 5
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 3 - 36
Steps for Creating a WSDL File Using JDeveloper
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 3 - 37
Creating a WSDL File Using JDeveloper
Component
Palette
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 3 - 38
Creating a WSDL File Using JDeveloper
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 3 - 39
Mapping of a Java Method to WSDL
Java method:
public String add(int param1, float param2); 1
WSDL:
...
<message name="addRequest"> 2
<part name="param1" type="xsd:int"/>
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 3 - 40
Mapping of a Java Method to WSDL
WSDL:
3
...
<binding name="MyWebServiceSoapHttp" ... >
<soap:binding style="rpc" ... />
<operation name="add">
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 3 - 41
WSDL Message Exchange Patterns
One-way messaging
Service
Sender SOAP message
Receiver
Request
Service
Sender
Response Receiver
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 3 - 42
Summary
Summary
This slide summarizes what you have learned in this lesson.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 3 - 43
Practice 3 Overview:
Creating WSDL-Based Contracts
This practice covers the following topics:
• Creating a WSDL file
• Adding an operation to a WSDL file
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 3 - 44
Implementing JAX-WS Web Services:
Server Side
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Objectives
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 4 - 2
JAX-WS 2.1 Features
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 4 - 3
JAX-WS 2.1 Features (continued)
XML catalogs
JAX-WS provides support for XML Catalogs as defined by the OASIS XML Catalogs 1.1
specification. All of the JAX-WS APIs and annotation that take a WSDL URI use the XML Catalogs
to resolve the WSDL document’s location. If your WSDL documents have imported external
schemas, an XML Catalog lets you map external references to imported schemas to local instances of
such schemas.
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, and so on. Using binding declarations you can also control certain features, such as
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 4 - 4
Server-Side JAX-WS Run Time
Client
Web
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 4 - 5
Service Granularity
• Service granularity:
– Is a measure of the number of operations, amount of
processing done, and message size
– Is a trade-off between network latency and usability
• Fine-grained services tend to have:
Service Granularity
Ultimately, a good Service-Oriented Architecture (SOA) should expose the right services that do the
right things, and be less concerned about granularity. Granularity can also be seen as measure of the
interaction between a service consumer and provider to address the business requirements. Fine-
grained services perform smaller tasks and process smaller quantities of data. A coarse-grained
service performs larger tasks on more data in a given interaction.
Fine-grained services generally:
• Provide many operations
• Execute smaller processing tasks
• Exchange smaller message sizes
• Require many calls which, when called remotely, can degrade performance a lot, due to higher
communication overhead
Coarse-grained services generally:
• Expose fewer operations
• Execute a larger amount of processing
• Exchange larger messages structures for operation request and response values
• Require fewer calls to do the same amount of work, which lessens the communication overhead
• Provide more business value than fine-grained services
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 4 - 6
Designing Coarse-Grained Interfaces
Coarse-grained interfaces:
• Pass as much useful data as needed for each request
• Return as much useful data as needed with each response
• Define all messages structures using an XML schema to
define complex data types for requests and responses
Fine-grained Coarse-grained
interfaces interfaces
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 4 - 7
JAX-WS Development Model
Server
• SEI
– POJO-based Bottom-up
– Using EJB 3.0
• Provider API
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 4 - 8
Steps for Implementing Web Services Using
POJOs
1. Add the annotations to the Java class and the optional
service endpoint interface.
2. Compile the endpoint implementation class or Service
Implementation Bean (SIB).
3. Generate portable artifacts required for Web service
execution (optional).
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 4 - 9
Using Annotations
Using Annotations
Using annotations, the service endpoint implementation can independently describe the Web service
without requiring a WSDL file. Annotations can provide all of the WSDL information necessary to
configure your service endpoint implementation or Web services client.
You can annotate methods, types, fields, and parameters in your Java class to specify a Web service.
@WebMethod annotation is applicable for public methods in a SEI, or in a service implementation
class. @WebMethod annotation is only supported on classes that have the @WebService
annotation. All public methods are treated as exposed, even if the @WebMethod annotation is not
specified. When you use the @WebService annotation, several rules control how methods are
exposed in your Web service and how you can use the @WebMethod annotation:
• If the @WebService annotation of an implementation class refers to a SEI, the
implementation class cannot have @WebMethod annotations.
• In an SEI or in an implementation class that does not refer to an SEI, if a @WebMethod
annotation has an attribute of exclude=true, the method is not exposed.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 4 - 10
Using Annotations (continued)
On the methods that are exposed in your Web service, use the @WebParam and @WebResult
annotations to customize the mapping of your parameters and results to message parts and XML
elements.
• @WebParam: Associates a SEI method’s parameter with a particular wsdl:part (rpc style) or a
wrapper child of a particular wsdl:part’s element definition (document style). In either case, the
@WebParam associates a Java representation of a parameter with the WSDL/SOAP
representation.
• @WebResult: Associates the SEI method’s return value to a wsdl:part or the wsdl:part’s
element definition.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 4 - 11
JSR 181 Annotations
Name Description
@WebService Marks either a Java class or a service endpoint interface
(SEI) as a Web service interface
@SOAPBinding Specifies the mapping of the Web service onto the SOAP
message protocol
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 4 - 12
Complex Return Results
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 4 - 13
Web Service Life Cycle
Ready
Business methods
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 4 - 14
PostConstruct and PreDestroy Life Cycle
Annotations
import javax.annotation.PreDestroy;
import javax.annotation.PostConstruct;
. . .
@WebService
public class MyWebService {
@PreDestroy
The methods can have any name,
public void destroy() {
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 4 - 15
PostConstruct and PreDestroy Life Cycle Annotations (continued)
Note: Don’t rely solely on PreDestroy. There are situations where the container might never call
your bean’s PreDestroy method, for example if the server crashes or a system exception occurs.
When a system exception occurs, the container invalidates the web services session object and
destroys the instance (moving it to the Does Not Exist state), without invoking any PreDestroy
methods.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 4 - 16
An Example of POJO-Based Service Endpoint
@SOAPBinding(style = SOAPBinding.Style.RPC)
@WebService
public class Math {
@WebMethod(operationName=“add1”)
public double add(@WebParam(name="num1") double num1,
@WebParam(name = "num2") double num2){
return num1+num2;
}
Associates a
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 4 - 17
An Example of POJO-Based Service Endpoint
@SOAPBinding(style = SOAPBinding.Style.RPC)
.. Map to WSDL
soap:binding
element’s style
<binding name="MathPortBinding" type="tns:Math"> attribute.
<soap:binding
transport="http://schemas.xmlsoap.org/soap/http"
style="rpc"/>
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 4 - 18
Quiz
Answer: 3
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 4 - 19
Implementing Web Services Using EJB
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 4 - 20
An Example of EJB Endpoint
import javax.ejb.Stateless;
import javax.jws.WebService;
From EJB 3.0
@Stateless
@WebService Turns stateless session EJB into WS
public class Math {
public Math() {}
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 4 - 21
The Provider API: Working with XML Directly
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 4 - 22
A Sample of Provider Endpoint
import javax.xml.ws.Provider;
import javax.xml.ws.WebServiceProvider;
import javax.xml.ws.ServiceMode
import javax.xml.transform.Source;
@WebServiceProvider
@ServiceMode(Service.Mode.PAYLOAD)
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 4 - 23
Creating Web Services from a WSDL File
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 4 - 24
A Sample WSDL and Generated Java File
<definitions
targetNamespace="urn:AdvMath“> Generated Java
... implementation file
<portType name="AdvMath"> 1 @WebService(name="AdvMath", 1
<operation name="multiply"> 2 targetNamespace =
<input message="tns:request"/> "urn:AdvMath",
<output message="tns:response"/>
</operation>
serviceName =
"AdvMathService",
4
</portType> portName =
"AdvMathPort", 5
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 4 - 25
A Sample WSDL and Generated Java File
@WebMethod
@WebResult(name = "result", partName = "result")
public double multiply( 2
@WebParam(name = "num1", partName ="num1") double num1,
@WebParam(name = "num2", partName = "num2") double num2) {
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 4 - 26
Quiz
Answer: 8
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 4 - 27
Summary
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 4 - 28
Practice 4 Overview:
Creating Server-Side Web Services
This practice covers the following topics:
• Implementing a contract-based Web Service
• Building JAX-WS–based Web Services
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 4 - 29
Oracle University and Egabi Solutions use only
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Implementing JAX-WS Web Services:
Client Side
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Objectives
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 5 - 2
Agenda
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 5 - 3
JAX-WS Client-Side Programming Model
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 5 - 4
Accessing Web Services
. . . Connect to the
port.someMethod(. . . ); service, and obtain a
callable stub.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 5 - 5
Service Objects
Service Objects
Service instances can be created dynamically or statically. For dynamic generation, the Service
is created at runtime by one of the Service.create factory methods:
public static Service create (QName serviceName)
public static Service create (URL wsdlDocumentLocation, QName
serviceName)
You must pass the service name and optionally the location of the WSDL document. For example:
URL wsdlLocation = new URL("http://example.org/my.wsdl");
QName serviceName = new QName("http://example.org/sample",
"MyService");
Service s = Service.create(wsdlLocation, serviceName);
Alternatively, during development, you can generate a subclass of Service from a WSDL
document using the JAX-WS tools, such as clientgen Ant task or JDeveloper.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 5 - 6
Invoking a Web Service with Proxy
Web Service
Service 1 WSDL to Java
Endpoint Mapping Tool
Interface (clientgen) WSDL
Develop time
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 5 - 7
Clients and Web Services
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 5 - 8
Generated Client Artifacts
JDeveloper
Class Interface
HelloWorldService (implements HelloWorld
Java.xml.ws.Service)
(SEI)
@WebServiceClient()
Stand-alone
HelloWorldPortClient
Generated
Proxy instance (implements sayHello (…) artifacts
HelloWorld SEI) Created at
run time
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 5 - 9
HelloWorld Web Service (Server-Side)
@WebService
public class HelloWorld {
public String sayHello(String s) {
String result = "hello";
if ( s == null || s.isEmpty()) {
return result + " unknown!";
}
return result + " " + s;
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 5 - 10
HelloWorld Web Service WSDL File
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 5 - 11
HelloWorld Web Service WSDL File
<wsdl:message name="sayHelloOutput">
<wsdl:part name="parameters" element="tns:sayHelloResponse"/>
</wsdl:message>
<wsdl:portType name="HelloWorld"> Maps to HelloWorld
<wsdl:operation name="sayHello"> (SEI) on client side
<wsdl:input message="tns:sayHelloInput“ .../>
<wsdl:output message="tns:sayHelloOutput“ .../>
</wsdl:operation>
</wsdl:portType>
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 5 - 12
Generated HelloWorld (Client-Side)
@WebService(wsdlLocation="HelloWorldService.wsdl",
targetNamespace=“…” name="HelloWorld")
@XmlSeeAlso( A mapped SEI
{ com.library.wsclient.ObjectFactory.class }) must be annotated
public interface HelloWorld Identifies that the with @WebService.
associated method is
{
mapped from a
@WebMethod wsdl:operation.
@RequestWrapper(localName="sayHello", Defines the wrapper
element for the SOAP
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 5 - 13
Generated HelloWorldService
@WebServiceClient(wsdlLocation=“…", name="HelloWorldService")
public class HelloWorldService
extends Service
{
…
public HelloWorldService()
{
super(wsdlLocationURL,
Generated HelloWorldService
This slide shows the code of HelloWorldService.java, which extends
java.xml.ws.Service. At runtime, JAX-WS needs to generate an instance of a SEI that
enables the programmer to invoke a Web service by invoking the method on the SEI. This file
implementing javax.xml.ws.Service acts as a factory class that can generate instances of the
SEI.
With @WebServiceClient annotation, it represents a client view of the Web service. The
getHelloWorldPort() method, annotated with @WebEndpoint, is used to obtain a run-time
instance of the SEI. Notice that internally it calls Service.getPort method.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 5 - 14
Enabling Features: WebServiceFeature
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 5 - 15
Generated HelloWorldPortClient
Generated HelloWorldPortClient
HelloWorldPortClient is the stand-alone Java program to accesses the sayHello method of
HelloWorldService. To do that, it needs to create an instance of the HelloWorldService
class, in turn uses the instance’s getHelloWorldPort() method to create a proxy instance that
implements the SEI. These code are generated by the tool, and you are responsible to add code to
accesses the sayHello method of HelloWorldService.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 5 - 16
BindingProvider Interface
BindingProvider Interface
The BindingProvider interface provides access to the protocol binding and associated context
objects for request and response message processing.
When a BindingProvider does a request/response, the request and response messages are
embedded in a context that is binding-specific. The message and its context move through a chain of
handlers during the invocation process. This is discussed further in the lesson titled “Using Handlers
in JAX-WS Web Services.”
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 5 - 17
Tools for Generating a Web Service Proxy
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 5 - 18
Creating a Web Service Proxy Using JDeveloper
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 5 - 19
Creating a Client JAR Using Ant
<taskdef name="clientgen"
classname=
"weblogic.ant.taskdefs.webservices.clientgen.ClientGenTask"/>
<target name="build-client">
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 5 - 20
Injecting Web Service References
@ServiceClient(wsdlLocation="...WebService?WSDL",
serviceName="WebService",portName="WebServicePort")
private WebPortType port;
. . .
Port.doSomething(. . . );
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 5 - 21
Quiz
Answer: 2
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 5 - 22
Agenda
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 5 - 23
Dispatch Client API
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 5 - 24
Using the Dispatch API for XML Messaging
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 5 - 25
Dispatch Client Support Matrix
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 5 - 26
A Sample of Dispatch Client
Qnames for service
as defined in
WSDL
QName serviceName =
new Qname("http://www.example.com/services/HelloWorld",
"HelloWorldService");
Create a dynamic
Service instance
Service service = Service.create(serviceName);
Create QName for
QName portName = the service port
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 5 - 27
Invoking a Web Service Using the Dispatch API
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 5 - 28
Agenda
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 5 - 29
JAX-WS Web Services Invocation Mechanisms:
Synchronous
• Both Proxy and Dispatch clients support synchronous and
asynchronous invocations.
• Synchronous invocation:
– Clients are blocked until operation completes.
– Clients are immediately aware of invocation failures.
The client’s calling thread is blocked until the Web service has finished processing.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 5 - 30
JAX-WS Web Services Invocation Mechanisms:
Asynchronous
Asynchronous invocation:
• Clients are decoupled from operation execution.
• Clients may not be directly aware of invocation failures.
• Invocations are typically more scalable and less
vulnerable.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 5 - 31
Asynchronous Invocation Models
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 5 - 32
HelloWorld (SEI) with Asynchronous Method Calls
@WebService(wsdlLocation="HelloWorldService.wsdl",
targetNamespace=“…” name="HelloWorld")
@XmlSeeAlso(
{ com.library.wsclient.ObjectFactory.class })
public interface HelloWorld
{
@WebMethod Synchronous
@ResponseWrapper(…) method call
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 5 - 33
HelloWorld (SEI) with Asynchronous Method Calls
@WebMethod(operationName="sayHello")
…
public Future<?> sayHelloAsync(
@WebParam(targetNamespace="", name="arg0")
String arg0,
AsyncHandler<com.library.ws.async.SayHelloResponse>
asyncHandler);
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 5 - 34
HelloWorldPortClient: Asynchronous Polling
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 5 - 35
Asynchronous Callback: Sequence Diagram
Client
main thread
1: new HelloWorldService()
2: getHelloWorldPort()
8: done=true 7: handleResponse
Response)
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 5 - 36
HelloWorldPortClient: Asynchronous Callback
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 5 - 37
HelloWorldPortClient: Asynchronous Callback
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 5 - 38
Creating an SEI Proxy Using the Asynchronous
Invocation Models
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 5 - 39
Creating a Dispatch Client Using the Polling
Asynchronous Invocation Model
Steps for creating a dynamic Dispatch client using the
asynchronous polling model:
1. Create a dynamic service instance.
2. Create QName for the service port.
3. Create a Dispatch instance using one of Service class
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 5 - 40
Dispatch Client: Asynchronous Polling
QName serviceName =
new Qname("http://www.example.com/services/HelloWorld",
"HelloService");
Response<Source> responseSource =
dispatch.invokeAsync(xmlSource);
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 5 - 41
Creating a Dispatch Client Using the Callback
Asynchronous Invocation Model
Creating a Dispatch client using the asynchronous callback
model, you need to:
1. Create a dynamic Service instance
2. Create QName for the service port
3. Create Dispatch instance by using one of
service.createDispatch(…) methods
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 5 - 42
Dispatch Client: Asynchronous Callback
…
Step 3
Dispatch<Source> dispatch = service.createDispatch(portName,
Source.class, Service.Mode.MESSAGE);
Step 4
AsyncHandler<Source> asyncHandler =
new AsyncHandler<Source>() {
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 5 - 43
Quiz
An asynchronous callback:
1. Is called repeatedly in user code to determine whether a
Web service is complete
2. Is called by the framework at call completion
3. Both
Answer: 2
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 5 - 44
Summary
Summary
This slide summarizes what you have learned in this lesson.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 5 - 45
Practice 5 Overview: Accessing Web Services
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 5 - 46
Packaging, Deploying, and Managing Web
Services
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Objectives
Objectives
This lesson discusses packaging and deploying Web services endpoints to WebLogic Server, as well
as managing endpoints using WebLogic Server Administration Console. This lesson also discusses
various components that can be included in the package and different deployment options.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 6 - 2
Web Services Packaging and Deployment
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 6 - 3
Port Component
A port component:
• Defines the artifacts that get packaged and deployed to the
container to implement a Web service
• Includes:
– Service Implementation Bean (SIB) (required)
Port Component
A port component is an addition to the Java EE platform defined by WSEE and can be considered the
Web services counterpart to other deployable components such as servlets and JSPs or EJBs. Like
those other components, a port component depends on the functionality provided by the Web and
EJB containers.
A port component defines the artifacts that make up a portable Web service application. These
components are defined in detail by the WSEE specification. A port component must include a
service implementation bean (SIB), and may optionally include a SEI, a WSDL document, and a
Web services deployment descriptor (webservices.xml).
• SIB: Is a Java class that contains the business logic of a Web service. It may also be a wrapper
that invokes other classes containing the business logic. A SIB must be annotated with
@WebService or @WebServiceProvider.
• SEI: Is a Java interface. If a SEI is included in a port component, the container uses the SEI
(including its annotations) to generate the WSDL file of the Web service. If no SEI is present,
the container generates the WSDL representation directly from the SIB.
• Web services deployment descriptor (webservices.xml): The file is not required by
JAX-WS because you can use annotations to specify all of the information that is contained
within this file. However, you may want to use a webservices.xml if you need to override
any existing JAX-WS annotations or deploy legacy classes.
• WSDL: When a WSDL document is provided in a port component, the container does not
generate WSDL, but rather uses the document supplied.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 6 - 4
Packaging a POJO Endpoint
WAR
WEB-INF
WSDL web.xml
SIB
webservice.xml
SEI weblogic-web.xml
jax-ws-catalog.xml
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 6 - 5
Packaging a POJO Endpoint (continued)
• Vendor-specific-web.xml (optional): A vendor specific Web application descriptor. In case of
WebLogic Application Server, it is weblogic.xml. The file is contained in the WEB-INF/
directory.
• jax-ws-catalog.xml (optional): This file is used in connection with OASIS XML Catalog. It is
contained in the WEB-INF/ directory.
• lib (optional): Any classes the SIB or SEI depend on are bundled in a JAR and contained under
the WEB-INF/lib directory where they are available on the application classpath.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 6 - 6
Packaging an EJB Endpoint
WEB-INF
EAR WAR
JAR
EJB-JAR
ejb-jar.xml wsdl
webservice.xml SIB
weblogic-ejbjar.xml
SEI
jax-ws-catalog.xml WSDL
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 6 - 7
WLS Container Deployment Processing
1
Process
annotations
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 6 - 8
WLS Container Deployment Processing
5
Is there a Y
Use WSDL file
WSDL file
6
7 N
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 6 - 9
Deploying Web Services Without a Deployment
Descriptor
With Java EE 5, you can deploy a servlet/EJB endpoint:
• With only a SIB
• With a SIB and WSDL
HelloWorld SIB
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 6 - 10
WSDL Generated from the SIB
<portType name="HelloWorld">
<operation name="sayHello">
<input message="tns:sayHello"/>
<output message="tns:sayHelloResponse"/>
</operation>
</portType>
<binding name="HelloWorldPortBinding" type="tns:HelloWorld">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"
style="document"/>
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 6 - 11
Supplying a WSDL File
@WebService(wsdlLocation="WEB-INF/wsdl/helloWorld.wsdl")
public class HelloWorld {
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 6 - 12
Deploying Web Services with a Deployment
Descriptor
• Information defined in the deployment descriptors
overrides any corresponding information that is specified
by annotations.
• You can use Web services deployment descriptor in the
following scenarios:
– Customizing the endpoint URL where a service gets
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 6 - 13
Customizing Endpoint URLs
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 6 - 14
Example Deployment Descriptors
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 6 - 15
Example Generated WSDL File
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 6 - 16
Overview of webservice.xml and
weblogic-webservice.xml
• The webservice.xml deployment descriptor file:
– Defines the set of Web services that are to be deployed to a
Java EE-enabled container
– Is optional
– Is used only to override existing annotation attributes or
specify attributes that are not defined by the annotation
<webservices ...>
<webservice-description> @WebService.wsdlLocation
<display-name>HelloWorld</display-name>
<wsdl-file>WEB-INF/wsdl/HelloWorld.wsdl</wsdl-file>
<port-component> @WebService.name
<port-component-name>HelloWorldPort</port-component-name>
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 6 - 18
Using webservice.xml to Override Annotations
@WebService(wsdlLocation=”http://example.com/location/of/the/w
sdl/MyService.wsdl”)
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 6 - 19
Quiz
Answer: 4
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 6 - 20
Packaging and Deployment Tools
• JDeveloper
• OEPE
• WebLogic Ant : jwsc, clientgen, schemagen, and
wldeploy
• Apache Ant: An open source tool creates packages in a
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 6 - 21
Deploying Web Services by Using JDeveloper
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 6 - 22
Deploying Web Services Using OEPE
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 6 - 24
Steps for Deploying a Web Service with
an SIB and WSDL
Steps for supplying your own WSDL:
1. Right-click the class and select “Show WSDL for Web
Service Annotations.”
2. Use Tools > Copy WSDL Locally to place the WSDL either
under your project’s source or the public_html
directory.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 6 - 25
Using jwsc Ant to Package Web Services
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 6 - 26
Updating the build.xml File for the jwsc Ant
Task
To run the jwsc Ant task, add the following taskdef and
build-service targets to the build.xml file:
<taskdef name="jwsc"
classname="weblogic.wsee.tools.anttasks.JwscTask" />
<target name="build-service">
<jwsc
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 6 - 27
Using the wldeploy Ant Task to Deploy Web
Services
To use the wldeploy Ant task, add the following target to your
build.xml file:
<target name="deploy">
<wldeploy action="deploy"
name="DeploymentName"
source="Source" user="AdminUser"
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 6 - 30
Basics of WebLogic Server Administration
Console
Administration Console is:
• Used to manage:
– A WebLogic Server domain
– One or more WebLogic Server instances
– Deployed applications, including Web services
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 6 - 31
Basics of WebLogic Server Administration Console (continued)
To invoke the Administration Console in your browser, enter the following URL:
http://hostname:port/console where
• hostname t refers to the computer on which the Administration Server is running.
• port refers to the port number where the Administration Server is listening for connection
requests. The default port number for the Administration Server is 7001.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 6 - 32
Managing Web Services by Using the
Administration Console
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 6 - 33
Web Service Configuration
A variety of Web
service
characteristics
can be managed
via the console.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 6 - 34
Configuring a Policy
Policy can be
configured using the
Configuration > WS-
Policy tab.
Configuring a Policy
Web Service policy can be configured using the console rather then applied directly to a Web service
via an annotation. To add policy to a web service. Select the web service, choose its configuration tab
and then using the WS Policy tab add specific policy.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 6 - 35
Testing via the Console
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 6 - 36
Quiz
Answer: 4
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 6 - 37
Summary
Summary
This slide summarizes what you have learned in this lesson.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 6 - 38
Practice 6 Overview:
Packaging and Deploying Web Services
This practice covers the following topics:
• Deploying a packaged Web Service
• Creating and deploying a Web Service via Ant
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 6 - 39
Oracle University and Egabi Solutions use only
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Fault and Exception Handling in JAX-WS Web
Services
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Objectives
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 7 - 2
What Are SOAP Faults?
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 7 - 3
Java and SOAP Faults
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 7 - 4
Unmodeled Faults
• Unmodeled faults:
– They are generated by JAX-WS when no business logic fault
is defined in WSDL.
– SOAP Fault elements are created in the response.
• Typical client-side Java exceptions include:
Often referred to as
– SOAPFaultException
Un-modeled Faults
Unmodeled faults are faults generated by JAX-WS ,when no corresponding exception is defined in
WSDL, such as JAX-WS run-time exceptions, NullPointerException.
There are three types of exceptions:
• SOAPFaultException and its relatives, used when the client receives an un-modeled fault
• WebServiceException, used in the JAX-WS APIs
• ExecutionException, used in asynchronous client programs
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 7 - 5
Common Unmodeled Faults
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 7 - 6
SOAP Fault Structure
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 7 - 7
SOAP 1.1 Fault
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 7 - 8
SOAP 1.1 Standard Fault Codes
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 7 - 9
SOAP 1.1 Fault Message Example
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 7 - 10
SOAP 1.2 Faults
detail e:Detail
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 7 - 11
SOAP 1.2 Fault Codes
The standard fault codes for SOAP 1.2 fault messages are:
• VersionMismatch
• MustUnderstand
• Sender: Renamed from SOAP 1.1 Client
• Receiver: Renamed from SOAP 1.1 Server
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 7 - 12
SOAP 1.2 Fault Message Structure
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 7 - 13
SOAP 1.2 Fault Message Example
<?xml version='1.0' ?>
<env:Envelope xmlns:env= http://www.w3.org/2003/05/soap-envelope >
<env:Body>
<env:Fault>
<env:Code>
<env:Value>env:Sender</env:Value>
<env:Subcode>
<env:Value>rpc:BadArguments</env:Value>
</env:Subcode>
</env:Code>
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 7 - 14
JAX-WS Fault Processing Infrastructure
Processing Other
classes
SOAP Business exceptions
Response translated to specific,
JAX-WS Runtime Services if possible, faults.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 7 - 15
Quiz
Answer: 2
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 7 - 16
Creating Modeled Faults
Client Server
MyService.wsdl
WSDL to Java tool MyService.java
Client artifacts
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 7 - 17
Web Service and Exception
SIB: HelloWorld.java
@WebService Results in modeled fault.
public class HelloWorld {
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 7 - 18
Web Service WSDL with Fault Message
HelloWorldService.wsdl
<?xml version="1.0" encoding="UTF-8"?> JAXB uses the type
<wsdl:definitions ...> definition in schema to
<wsdl:types> map create
<schema xmlns=...> MissingName.java
<xsd:complexType name="sayHello"> that has a “Message”
<xsd:sequence> property and extends
<xsd:element name="arg0" type="xsd:string"/>
exception.
</xsd:sequence>
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 7 - 19
Web Service WSDL with Fault Message
<wsdl:message name="MissingName">
<wsdl:part name="MissingName" element="tns:MissingName"/>
</wsdl:message>
<wsdl:portType name="HelloWorld"> Gets mapped to the
<wsdl:operation name="sayHello"> exception class:
<wsdl:input message="tns:sayHelloInput“ .../> MissingName.java
<wsdl:output message="tns:sayHelloOutput“ .../>
<wsdl:fault name="MissingName" message="tns:MissingName"/>
</wsdl:operation>
</wsdl:portType>
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 7 - 20
FaultBean Class (Generated JavaBean)
MissingName.java
package com.library.ws.mfclient.type
import...
@XmlAccessorType(XmlAccessType.FIELD) Used to contain the
@XmlType(name = "MissingName", propOrder = { “content” of the fault
"message" and used “inside” the
}) associated generated
public class MissingName { client-side exception.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 7 - 21
Exception Class
MissingName.java
Package com.library.ws.mfclient
import javax.xml.ws.WebFault;
@WebFault(faultBean="com.library.ws.mfclient.type.MissingName",
targetNamespace="http://ws.library.com/", name="MissingName")
public class MissingName
extends Exception {
Exception Class
JAX-WS uses the @WebFault annotation to identify this class as a exception. It is a wrapper class
for the fault bean.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 7 - 22
Exception Class
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 7 - 23
Client-Side Service Implementation
HelloWorld.java (SEI)
@WebService(wsdlLocation="HelloWorldService.wsdl", ...)
@XmlSeeAlso(
{ com.library.ws.faultclient.ObjectFactory.class })
public interface HelloWorld
{
@WebMethod
...
public String sayHello(@WebParam(targetNamespace="", name="arg0")
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 7 - 24
Client
HelloWorldPortClient.java
public class HelloWorldPortClient
{
@WebServiceRef
private static HelloWorldService helloWorldService;
Client
The above code from HelloWorldPortClient class is used to create a proxy instance, and
invoke the sayHello method of HelloWorld Web service. Note that the code that exercises the
sayHello method has catch blocks to handle any MissingName exceptions that might get
thrown.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 7 - 25
Creating Modeled Faults
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 7 - 26
Implicit Fault Example on the Server Side
SIB: HelloWorld.java
@WebService
public class HelloWorld {
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 7 - 27
Implicit Fault Example on the Client Side
HelloWorldPortClient.java
public class HelloWorldPortClient
{
@WebServiceRef
private static HelloWorldService helloWorldService;
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 7 - 28
Exceptions in the Log File
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 7 - 29
Quiz
Answer: 1
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 7 - 30
Summary
Summary
This slide summarizes what you have learned in this lesson.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 7 - 31
Practice 7 Overview:
Handling Web Service Exceptions
This practice covers the following topics:
• Working with exceptions: Services
• Working with exceptions: Client
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 7 - 32
Web Services Security
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Objectives
Objectives
This lesson discusses how to use WS-Security and WS-Policy to enforce security on the message
level for the Web Services.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 8 - 2
Overview of Web Services Security
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 8 - 3
Transport-Level Security
Transport-Level Security
Transport-level security uses SSL to secure the connection between a client application and the Web
Service. SSL provides secure connections by allowing two applications connecting over a network to
authenticate the other's identity and by encrypting the data exchanged between the applications.
Transport-level security, however, secures only the connection itself. This means that if there is an
intermediary between the client and server, such as a router or message queue, the intermediary gets
the SOAP message in plain text. When the intermediary sends the message to a second receiver, the
second receiver does not know who the original sender was and may not use SSL. Additionally, the
encryption used by SSL is "all or nothing": either the entire SOAP message is encrypted or it is not
encrypted at all. There is no way to specify that only selected parts of the message be encrypted.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 8 - 4
Message-Level Security
• Message-level security:
– Specifies whether the SOAP messages between a client
application and the Web service should be:
— Digitally signed (to ensure data integrity)
— Encrypted (to ensure confidentiality)
– Assures authentication, by requiring username, X.509, or
Message-Level Security
Message-level security specifies whether the SOAP messages between a client application and the
Web Service should be digitally signed or encrypted, or both. It also can specify a shared security
context between the Web Service and client in the event that they exchange multiple SOAP
messages. You can use message-level security to assure:
• Confidentiality, by encrypting message parts
• Integrity, by digital signatures
• Authentication, by requiring username, X.509, or SAML tokens
Security data are built in to the XML message text, usually as additional SOAP header fields.
Message-level security includes all the security benefits of SSL, but with additional flexibility and
features. Message-level security is end-to-end, which means that a SOAP message is secure even
when the transmission involves one or more intermediaries. The SOAP message itself is digitally
signed and encrypted, rather than just the connection. And finally, you can specify that only
individual parts or elements of the message be signed, encrypted, or required.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 8 - 5
WS-Security Overview
WS-Security Overview
Web Services Security (WS-Security) specification specifies the Web services security at message
level. IBM and Microsoft defined the specification, which is OASIS approved, “Web Services
Security: SOAP Message Security”.
WS-Security is a collection of protocols that specify how different levels of security can be enforced
on messaging in SOAP-based web services. It is meant to provide comprehensive end-to-end
message content security and not just transport-level security. The security matters are not delegated
to the transport level but rather handled directly through an appropriate security API.
WS-Security defines SOAP extensions to implement client authentication, data integrity and data
confidentiality on the message level.
• Data confidentiality is to make sure that the data can't be read during transit, by means of
message encryption. WS-Security uses the XML Encryption specification to encrypt portions of
the SOAP messages. Any portions of SOAP messages, including headers and body blocks may
be encrypted.
• Data integrity ensures the recipient that the data that application receives has not been altered
during transit. It is implemented by XML Signature in WS-Security. XML Signature binds the
sender's identity (or "signing entity") to an XML document. Signing and signature verification
can be done using asymmetric or symmetric keys.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 8 - 6
WS-Security Overview (continued)
• Authentication can be done using security tokens. WS-Security allows you to use any security
token you choose to use. Explicitly defined are three different options:
- Username/password authentication in case of custom authentication
- Binary authentication tokens in the form of Kerberos tickets or X.509 certificates
- Security Assertion Markup Language (SAML)
WS-Security defines how to attach XML Signature and XML Encryption headers to SOAP
messages, as well as a way of associating security tokens with a message.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 8 - 7
What Is SAML?
What Is SAML?
With WS-Security you can use any security token you want. SAML is one of the most interesting
security tokens. It is an open framework for sharing security information on the Internet through
XML documents. It enables different security services systems to interoperate.
SAML is the dominant standard for Federated Identity. Federated Identity uses information from
multiple, independently administered sources to implement security services such as authentication
and authorization.
SAML specification defines a standard, XML-based approach for passing security tokens defining
authentication and authorization rights. Originally, SAML was targeted more toward distributed
authentication and single sign-on (SSO), but those concepts are also central to Web services security
now.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 8 - 8
SAML Architecture
SAML Architecture
SAML includes three parts:
• SAML Assertion: A set of statements made by a SAML authority. It includes:
- Authentication statements
- Attribute statements
- Authorization statements
• SAML Protocol: SAML defines a request/response protocol for obtaining assertions
• SAML Bindings and Profiles: How SAML assertions ride “on” (Bindings) and “in”
• (Profiles) industry-standard transport and messaging frameworks.
- Bindings: A binding details how the SAML protocol maps onto transport and messaging
protocols.
- Profiles: Derived from use cases, they are technical descriptions of specific flows of
assertions and protocol messages.
The full SAML specification is used in browser-based federation cases. However, Web services
security systems only use SAML assertions. The protocol and bindings are taken care of by WS-
Security and the transport protocol, for example HTTP.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 8 - 9
WS-Security and SAML
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 8 - 10
WebLogic’s Support for SAML Token
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 8 - 11
WS-Security Architecture
Check Check
Sign Encrypt Add auth Decrypt
auth signature
token
token
WS-Security Architecture
The slide displays the WS-Security architecture. The WS-Security architecture is segregated into two
parts: client WS-Security interceptor and server WS-Security interceptor. An interceptor is a prebuilt
JAX-WS handler that implements all the WS-Security features, such as digital signatures, encryption,
and authentication.
Whenever a client has to send a SOAP request message to the server, the SOAP request message is
intercepted by the client interceptor. The interceptor adds the authentication, signature, and
encryption elements to the SOAP message, and then forwards the message to the Web service.
On receiving the message from the client, the Web service invokes the server interceptor that verifies
the signatures of the incoming SOAP message. If the signature is valid, the interceptor decrypts and
authenticates the message and forwards it to the Web service endpoint implementation. After
processing the client’s request, the Web service generates a SOAP response message that includes
the WS-Security header with integrity and confidentiality information. The message is then sent back
to the client.
On receiving the SOAP response message from the server, the client interceptor interprets the header
and delivers it to the client application.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 8 - 12
WS-Security Stack
WS- WS-
WS-Secure Conversation
Federation Authorization
SOAP Specification
Not supported in WLS Web Services and not adopted by the industry
WS-Security Stack
As shown above, the WS-Security is a family of specifications designed to augment transport-level
security by providing a unified, transport-neutral, end-to-end framework for higher levels of security
such as authorization. There are two layers above WS-Security: the first layer consists of WS-Policy,
WS-Trust, and WS-Privacy; the second layer of WS-Secure Conversation, WS-Federation, and WS-
Authorization builds upon this first layer.
First Layer
• WS-Policy: This specification describes general security capabilities, constraints, and policies.
For example, a WS-Policy assertion could stipulate that a message requires security tokens or
that a particular encryption algorithm be used.
• WS-Trust: This specification deals primarily with how security tokens are to be issued and
exchanged.
• WS-Privacy: Explains how services can enforce privacy policies. The specification also covers
how a service can determine whether a requester intends to follow such policies.
Second Layer
• WS-Secure Conversation: Secures web service conversations across different sites and,
therefore, across different security contexts and trust domains. The specification focuses on
how a security context is created and how security keys are derived and exchanged.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 8 - 13
WS-Security Stack (continued)
• WS-Federation: The specification addresses the challenge of managing security identities in a
heterogeneous security environment. It describes how to maintain a single, authenticated
identity across different platforms and organizations.
• WS-Authorization: Defines how Web services manage authorization data and policies.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 8 - 14
Quiz
Answers: 1, 2, 4
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 8 - 15
Quiz
Answer: 3
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 8 - 16
WS-Policy Overview
WS-Policy:
• Defines a framework for allowing Web Services to express
their constraints and requirements
• Provides a model and syntax for describing the policies of
a Web service.
WS-Policy Overview
WS Policy is used by Web services primarily to specify requirements that clients must satisfy in
order to use the Web service. The requirements cover security/encryption, transportation protocol
and so on. Basically, WS-policy provides the Web service an ability to specify requirements beyond
that normally definable by its WSDL specification. A policy consists of a set of rules written in XML
that are either incorporated directly into or referenced by the Web service's WSDL specification.
Web services Policy Framework, called as WS-Policy provides a model and syntax for describing the
policies of a web service.
WS-Policy includes the following specifications:
• WS-Policy - Defines a grammar which explains Web services policies
• WS-PolicyAttachment - Defines policy around using attachments
• WS-PolicyAssertions - Defines a set of general policy assertions
The constraints and requirements of Web services are expressed as policy assertions.
• WS-SecurityPolicy - Defines a set of security policy assertions for use with the WS-Policy
framework describing how messages are secured
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 8 - 17
Policy Assertion
• Policy assertion:
– Is a basic unit representing individual requirement in a policy
– Is domain specific (security, reliability)
• Service providers use a policy assertion to convey a
condition under which they offer a Web service.
Policy Assertion
A policy assertion is a piece of service metadata representing an individual requirement, capability,
or other property of a behavior. Assertions are domain (security, reliability and transaction) specific
and the details are specified in separate specifications. Service providers use a policy assertion to
convey a condition under which they offer a Web service. A policy-aware client can recognize policy
assertions and engage these behaviors automatically.
The policy expression (XML form of the policy) in the above example consists of a Policy main
element and a child element wsp:TextEncoding. Child elements of the Policy element are
policy assertions. This example represents a specific policy assertion for text encoding. A policy-
aware client can recognize this policy assertion, engage text encoding automatically.
Note: The prefix wsp is used here to denote the Web Services Policy XML Namespace.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 8 - 18
Policy Operators
Policy Operators
Policy assertions can be combined in different ways to express consistent combinations of behaviors
(capabilities and requirements). There are three policy operators for combining policy assertions:
Policy, All and ExactlyOne.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 8 - 19
Sample of a Policy File
<wsp:Policy xmlns:wsp=“http://schemas.xmlsoap.org/ws/2004/09/policy”
xmlns:wsap=“...” xmlns:ap=“...” >
<All>
<wsp:TextEncoding Encoding="iso-8859-5" />
<wsap:UsingAddressing />
<ExactlyOne>
<wsp:TransportBinding>
<Policy>
<sp:TransportToken>
<Policy>
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 8 - 20
WS-SecurityPolicy
WS-SecurityPolicy
The WS-Policy specification defines a framework for allowing Web Services to express their
constraints and requirements. Such constraints and requirements are expressed as policy assertions.
WS-SecurityPolicy defines a set of security policy assertions for use with the WS-Policy framework
to describe how messages are to be secured in the context of WSS: SOAP Message Security, WS-
Trust and WS-SecureConversation.
You configure message-level security for a Web Service by attaching one or more policy files that
contain security policy statements, as specified by the WS-SecurityPolicy specification.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 8 - 21
Quiz
Answer: 3
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 8 - 22
WebLogic WS-Security Support
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 8 - 23
Message-Level Security Configuration Using
Policy Files
• To configure the message-level security for WebLogic
Web services, you need to:
– Specify the details of message-level security with one or
more security policy files
– Use the @Policy and @Policies annotations in JWS file
to associate policy files with Web Service
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 8 - 24
Sample of Using @Policy and @Policies
Annotations
@WebService
@Policy(uri="policy:Wssp1.2-2007-Wss1.0-UsernameToken-Plain-
X509-Basic256.xml") Username token with
plain-text password is
public class SignAndEncrypt { Grouping of sent in the request for
policies Authentication.
@WebMethod
@Policies({
@Policy(uri="policy:Wssp1.2-2007-SignBody.xml"),
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 8 - 25
Specifying the Policy File Location
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 8 - 27
WebLogic Prepackaged Policy Files (continued)
Oracle recommends that you use the new policy namespace, as those are official namespaces from
OASIS standards and they will perform better when interoperating with other vendors. The old
policies having the prefix of "Wssp1.2-" are mainly for users who want to interoperate with existing
applications that already use this version of the policies.
The policy files are categorized as:
• Transport Level Policies: These policies require use of the https protocol to access WSDL and
invoke Web Services operations. The files include:
- Wssp1.2-2007-Https.xml
- Wssp1.2-2007-Https-BasicAuth.xml
- Wssp1.2-2007-Https-ClientCertReq.xml
- Wssp1.2-2007-Https-UsernameToken-Digest.xml
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 8 - 28
Associating Policy Files Using JDeveloper
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 8 - 29
Associating Policy Files at Run Time Using
Administration Console
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 8 - 30
Associating Policy Files at Run Time Using
Administration Console
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 8 - 31
Quiz
Answer: 3
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 8 - 32
Message Encryption and Signing Mechanisms
Use sender’s
MS public key private key to
MR public key
sign a message
MS
MSprivate
privatekey
key MR private key
MR public key MS
MSpublic
publickey
key
Signing
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 8 - 33
Configuring Message-Level Security
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 8 - 34
Configuring Message-Level Security (continued)
Note: keytool is a standard Java SE SDK utility for managing the generation of private keys and
corresponding digital certificates, and keystore of private keys and associated certificates. For more
information, see http://java.sun.com/javase/6/docs/tooldocs/solaris/keytool.html.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 8 - 35
Creating Key Pairs, Keystore on the Server Side
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 8 - 36
Web Service Security Configuration
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 8 - 37
Quiz
Answers: 2, 3
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 8 - 38
Invoking a Message-Secured Web Service
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 8 - 39
Sample Client Code
import weblogic.security.SSL.TrustManager;
import weblogic.xml.crypto.wss.provider.CredentialProvider;
...
public class SecureHelloWorldClient {
public static void main(String[] args) throws Throwable {
String username = args[0]; Username or
String password = args[1]; password for the
UsernameToken
String keyFile = args[2]; Client private key file
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 8 - 40
Sample Client Code
rc.put(WSSecurityContext.TRUST_MANAGER,
new TrustManager() {
public boolean certificateCallback(X509Certificate[] chain,
int validateErr) {
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 8 - 41
Invoking a Web Service from Within a WebLogic
Server Instance
• To invoke a Web service from one instance of WebLogic
Server to another, you must:
– Specify security using the Administration Console:
— Configure the required credential mapping providers of the core
security of the WebLogic Server instance.
— Create the actual credential mappings in the credential mapping
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 8 - 42
Invoking a Web Service from Within a WebLogic Server Instance (continued)
2. Using the Administration Console, configure the required credential mapping providers of the
core security of the WebLogic Server instance that hosts your client application. The list of
required credential mapper providers depends on the policy file that is attached to the Web
Service you are invoking. Typically, you must configure the credential mapper providers for
both username/password and X.509 certificates.
3. Using the Administration Console, create the actual credential mappings in the credential
mapping providers you configured in the preceding step. You must map the user principal,
associated with the client running in the server, to the credentials that are valid for the Web
Service you are invoking. See Configuring a WebLogic Credential Mapping Provider in Oracle
Fusion Middleware Securing Oracle WebLogic Server.
4. Using the Administration Console, configure the core WebLogic Server security framework to
trust the X.509 certificate of the invoked Web Service. See Configuring the Certificate Lookup
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 8 - 43
Oracle WSM WS-Security Policies
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 8 - 44
Adding Oracle WSM WS-Security Policies to a
Web Service
• The Oracle WSM WS-Security policy attachment model is similar
to that of the WebLogic Web service policies:
– Adding policy annotations at design time
— @SecurityPolicy (single policy)
— @SecurityPolicies (multiple policies)
– Using the Administration Console at run time
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 8 - 45
Nonsupported Oracle WSM WS-Security Policies
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 8 - 46
Summary
Summary
This slide summarizes what you have learned in this lesson.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 8 - 47
Practice 8 Overview:
Securing Web Services Using WS-Policy
This practice covers the following topics:
• Signing and encrypting Web services calls in services
• Creating secure Web service clients
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 8 - 48
Using Handlers in JAX-WS Web Services
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Objectives
Objectives
The goal of this lesson is to teach how to create and configure SOAP handlers to manipulate
SOAP messages that are sent and received by JAX-WS clients and service endpoints.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 9 - 2
SOAP Message Handlers
• Web Services and their clients may need to access the SOAP
message for additional processing of the message request or
response.
• SOAP message handlers:
– Provide a mechanism for intercepting the SOAP message in both
the request and response of the Web Service
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 9 - 4
Handler Types
Handler Types
JAX-WS supports two types of SOAP message handlers: logical handlers and SOAP handlers.
Logical handlers can access the payload of the message only, and cannot change any protocol-
specific information (like headers) in a message. SOAP handlers can access the entire SOAP
message, including the message headers and body.
SOAP Handler is a protocol specific handler. It can be used if we want to check the user
credentials, and then only allow to access the service. Logical Handler is a message oriented
interface. You can easily access messages and transform the messages in logical handler class.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 9 - 5
Handler Framework
Handler Framework
JAX-WS provides a handler framework that allows application code to manipulate outgoing and
incoming SOAP messages. A handler can be injected into the framework in two steps:
• One step is to create a handler class, which implements the Handler interface in the
javax.xml.ws.handler package. JWS provides two Handler subinterfaces,
LogicalHandler and SOAPHandler.
• The other step is to place the handler within a handler chain. This is typically done through
a configuration file, although handlers also can be managed through code or
programmatically.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 9 - 6
Creating Message Handlers
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 9 - 7
Quiz
Answers: 3, 5
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 9 - 8
Handler Interfaces
<<use>>
Handler
SOAPHandler LogicalHandler
getHeaders()
Handler Interfaces
The diagram illustrates the relationship of the message handler interfaces and methods.
To create a message handler, you need to implement the Handler interface in the
javax.xml.ws.handler package. JWS provides two Handler subinterfaces:
LogicalHandler and SOAPHandler. The class that implements either the LogicalHandler or the
SOAPHandler interface needs to define three methods for either interface type, including
handleMessage, which gives the programmer access to the underlying message. The other
two shared methods are handleFault and close. The SOAPHandler interface requires the
implementation to define a fourth method, getHeaders.
The details of methods in Handler interface are:
• handleMessage(): Called automatically when a request or response is sent (either on
server or client)
• handleFault(): Called automatically when there is a fault present in request or
response (either on server or client)
• close(): Called after the completion of message processing by all handlers for each
Web service invocation. This can be useful to clean up any resources used during
processing the message.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 9 - 9
Handler Life Cycle
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 9 - 10
Message Context
• Message context:
– Is used by JAX-WS to to exchange information between
client, client handlers, service, service run time, and service
handlers
– Contains a set of properties that are set by JAX-WS run time
automatically
Message Context
Message context (javax.xml.ws.handler.MessageContext) is the information
carrier among client, client runtime, client handlers, and service, service runtime, and server-side
handlers. It contains information about the message and the context of the message exchange,
such as information related to the binding protocol. JAX-WS enables handlers, endpoints, and
clients to manipulate a message context that travels along with the XML request/response
messages. The message context is maintained throughout the process of request handler and
response handler.
While invoking handlers, message context is sent as input to handlers’ call back methods. So
handlers can access and modify inbound and outbound messages and manage a set of properties.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 9 - 11
MessageContext Interface
Map<String,Object>
MessageContext
enum Scope
getMessage() getHeaders()
getMessage()
getRoles()
setMessage()
MessageContext Interface
MessageContext extends java.util.Map interface. The Map interface defines a key and
value pair collection. For MessageContext, the key is String type, and the value is Object
type.
MessageContext contains a set of properties which are set by JAX-WS runtime
automatically. To retrieve the value of each property, use get() method.
Some of the message context properties are:
• MESSAGE_OUTBOUND_PROPERTY (Boolean): It tells the message direction, if the value
is true then it is outbound messages, false is inbound message. Handlers use this property
to determine if the processing is on a outbound or inbound message.
• INBOUND_MESSAGE_ATTACHMENTS (java.util.Map): Attachments to an inbound
message. These can be used to acquire the attachments in inbound message.
• OUTBOUND_MESSAGE_ATTACHMENTS (java.util.Map): Attachments to an outbound
message. A proxy can use these to send attachments not described through WSDL MIME
binding.
Some properties are specific to the HTTP protocol and are available only in HTTP-based
bindings.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 9 - 12
MessageContext Interface (continued)
MessageContext has an embedded class MessageContext.Scope, which is an enum
defining property scope. Properties scoped as APPLICATION are visible to handlers, client
applications, or service endpoint implementations; those scoped as HANDLER are only visible to
handlers.
LogicalMessageContext is the context sent to logicalhandler.
SoapMessageContext is the message context sent to SOAPHandler.
SoapMessageContext consists of special methods to retrieve SOAP headers and SOAP
body content.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 9 - 13
MessageContext Injection in Web Services
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 9 - 14
Handler Interface Methods
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 9 - 16
A Simple Logical Handler Class
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 9 - 17
A Simple SOAP Handler Class
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 9 - 18
Quiz
Answers: 1, 3, 4
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 9 - 19
Handler Chain
Handler Chain
Developing handlers is only the first step. To use them in a Web service application, you must
configure and deploy them into the client or service runtime. Typically, you organize multiple
handlers according to an ordered list into handler chains. Handler configuration and deployment
use handler chains as units.
Handler chains have following properties:
• You can configure multiple Logical and SOAP handlers in a single handler chain
• When multiple handlers are configured in single chain the order of processing is different
for inbound and outbound messages. It actually depends on whether the source of message
is sender or receiver.
• Handler chains can be configured using annotation (that is,
@javax.jws.HandlerChain). Alternatively, on the client side, handler chains can be
configured at runtime using the HandlerResolver interface.
• The deployment of handlers specified using the @HandlerChain annotation requires
configuration files, which are handler chains' descriptor. The @HandlerChain
annotation contains a file attribute that points to this handler chain configuration file that
you create. WSEE specifies the deployment model for handlers, including the use of these
configuration files.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 9 - 20
Handler Chain (continued)
• Handler chains are defined at the port level—so all methods defined by a SEI must use the
same handler chain.
• Handlers in the handler chain have read/write access to the XML message and the
message’s context.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 9 - 21
WebLogic Server-Side Handler Execution
4
Handler1 Handler2 Handler3
handleMessage() handleMessage() handleMessage()
outbound outbound outbound
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 9 - 22
Handler Chain Processing Order
Chain 1 Chain 2
Processing order on the client side: Processing order on the server side:
outbound inbound
Client Service
JAX-WS JAX-WS
inbound outbound
Runtime Runtime
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 9 - 23
Configuring Handler Chains on the Server Side
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 9 - 24
Sample Service Implementation Class with
Handler Chain Annotation
@WebService
@HandlerChain(file="handler-chain.xml")
public class HelloWorldWS
{ Handler chain annotation with
@WebMethod() file attribute specifying the
location of configuration file
public String sayHello(String name) {
return "Hello " + name;
}
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 9 - 25
Sample Handler Chain Configuration File
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 9 - 26
Sample Handler Chain Configuration File
<jws:handler-chain name="MyHandlerChain2”>
<jws:handler>
<jws:handler-class>
com.example.ws.handler.SecurityHandler
</jws:handler-class> Second handler
</jws:handler> chain declaration
<jws:handler>
<jws:handler-class>
com.example.ws.handler.CryptographyHandler
</jws:handler-class>
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 9 - 27
Quiz
Answer: 1
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 9 - 28
Configuring Handler Chains on the Client Side
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 9 - 29
Configuring Handler Chains on the Client Side (continued)
Configuring client-side handler chains through metadata, the runtime actually uses the
@HandlerChain annotation and the default implementation of HandlerResolver class to build
the handler chain. This approach configures the client application with the same set of handler
chains for all message exchanges.
With programmatic configuration, you can also configure, through the custom
HandlerResolver class, different handler chains at the client runtime for different services,
ports, and protocol bindings.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 9 - 30
Implementing HandlerResolver Interface
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 9 - 31
Implementing HandlerResolver Interface (continued)
A Web service client application should register a HandlerResolver instance with a Service
instance. To register a handler resolver to the Service instance, use the
setHandlerResolver() method. In this case, the port proxy or Dispatch object created
from the Service instance uses the HandlerResolver to determine the handler chain.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 9 - 32
Using a Binding Interface
...
import javax.xml.ws.handler.Handler;
import javax.xml.ws.Binding;
import javax.xml.ws.BindingProvider;
import com.examples.ws.Handler1;
import com.examples.ws.Handler2;
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 9 - 33
Using a Binding Interface
...
Binding binding = ((BindingProvider)port).getBinding();
List<Handler> handlerList = binding.getHandlerChain();
handlerList.add(new Handler1());
handlerList.add(new Handler2());
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 9 - 34
Quiz
Answer: 2, 3
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 9 - 35
Adding Server-Side Handlers
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 9 - 36
Creating a Configuration File by Using
JDeveloper Wizard
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 9 - 37
Adding Client-Side Handlers
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 9 - 38
Summary
Summary
This slide summarizes what you have learned in this lesson.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 9 - 39
Practice 9 Overview:
Creating Handlers for Web Services
This practice covers the following topics:
• Writing a server-side logical handler
• Creating a handler chain configuration file
• Specifying the handler for a Web service
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 9 - 40
Optimizing Binary Data Transmission Using
MTOM/XOP
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Objectives
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 10 - 2
Challenges of Binary Data Transmission
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 10 - 3
SOAP Message with Text-Encoded Binary
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 10 - 4
SOAP with Attachment (SwA)
Communication
protocol envelope (HTTP)
MIME Package
SOAP Part
SOAP envelope
Body
Attachment part
SOAP attachment
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 10 - 5
Using MIME with SOAP
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 10 - 6
SOAP Message in MIME Package
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 10 - 7
SOAP Message in MIME Package
--MIME_boundary
Content-Type: image/jpeg
Content-Transfer-Encoding: binary
Content-ID: < QueryBook_1_image>
...binary PDF...
--MIME_boundary-—
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 10 - 8
Message Transmission Optimization Mechanism
(MTOM) Addresses Challenges
MTOM:
• Is a specification that defines a way to optimize the
transmission of wire format of SOAP messages
• Works together with XML-binary Optimization Packaging
(XOP) to:
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 10 - 9
XOP
XOP specifies the method for serializing a XML file with non-
XML attachments into MIME packages and works by:
• Extracting the binary data in an XML document
• Serializing the data into packages by using MIME
Multipart/Related packaging mechanism
XOP
XOP specifies the method for serializing a XML file with non-XML content into MIME packages.
XOP provides an alternate serialization that is fully compatible with a MIME package, including an
XML document as the root portion of the package.
XOP extracts all the binary data in an XML document and serializes the data into packages by using
the packaging mechanism MIME Multipart/Related. The new XML document marks the locations of
those binary data packages with special elements that contain URI identifying the corresponding
location.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 10 - 10
How MTOM/XOP Works
• MTOM:
– Serializes a SOAP message into a MIME
Multipart/Related XOP package
– One body part (the root) that contains an XML representation
of the modified SOAP envelope
– Additional parts that contain the binary representation of
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 10 - 11
MTOM/XOP Version of SOAP Message
POST /BookCatalog HTTP/1.1
Content-Type: Multipart/Related; boundary=MIME_boundary;
type=application/xop+xml;start-info="text/xml"
Media type Indicates SOAP 1.1 content type
--MIME_boundary
Content-Type: application/xop+xml; type="text/xml" charset=UTF-8
Content-Transfer-Encoding: 8bit
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 10 - 12
MTOM/XOP Version of SOAP Message
</ns1:book>
</soap:Body>
</soap:Envelope>
--MIME_boundary
Content-Type: application/octet-stream
Content-Transfer-Encoding: binary
Content-ID: < QueryBook_1_image>
Identifiers of the
...binary PDF...
--MIME_boundary-—
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 10 - 13
Quiz
Answer: 4
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 10 - 14
Enabling MTOM for JAX-WS Web Services
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 10 - 15
Using MTOM/XOP to Send Binary Data
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 10 - 16
MIME and Java Data Type Mappings
image/gif java.awt.Image
image/jpeg java.awt.Image
*/* javax.activation.DataHandler
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 10 - 17
Annotating the Data Types: Start from Java
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 10 - 18
Annotating the Data Types: Start from WSDL
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 10 - 19
Enabling MTOM on the Server Side: Annotation
With WLS, you can enable MTOM on the Web Service using an
annotation or WS-Policy file:
• Using annotation @MTOM
import javax.xml.ws.soap.MTOM;
...
}
}
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 10 - 20
Enabling MTOM on the Server Side: WS-Policy
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 10 - 21
Enabling MTOM on the Server Side: WS-Policy (continued)
You can associate the Mtom.xml WS-Policy file with a Web Service at development-time by
specifying the @Policy metadata annotation in your JWS file. Be sure you also specify the
attachToWsdl=true attribute to ensure that the dynamic WSDL includes the required reference
to the Mtom.xml file.
In addition, you can attach the file at runtime by using the Administration Console; for details, see
“Associate a WS-Policy file with a Web Service” in the Oracle Fusion Middleware Oracle
WebLogic Server Administration Console Help.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 10 - 22
Enabling MTOM by Using JDeveloper
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 10 - 23
Quiz
Answer: 2
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 10 - 24
Enabling MTOM on the Client Side
//Enable MTOM
SOAPBinding binding = (SOAPBinding) myBP.getBinding();
binding.setMTOMEnabled(true);
Enable MTOM
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 10 - 25
Enabling MTOM on the Client Side
import javax.xml.ws.soap.MTOMFeature;
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 10 - 26
Setting the Attachment Threshold
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 10 - 27
Quiz
Answers: 1, 2
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 10 - 28
Streaming MTOM
Streaming MTOM
Using MTOM and the javax.activation.DataHandler and
com.sun.xml.ws.developer.StreamingDataHandler APIs you can specify that a Web
Service use a streaming API when reading inbound SOAP messages that include attachments, rather
than the default behavior in which the service reads the entire message into memory. This feature
increases the performance of Web Services whose SOAP messages are particularly large.
The following several slides describe how to employ streaming SOAP attachments on the client and
server sides.
Note: The com.sun.xml.ws.developer.StreamingDataHandler API (see
https://jax-ws-architecture-document.dev.java.net/nonav/doc/com/sun/xml/ws/developer/
StreamingAttachment.html) is supported as an extension to the JAX-WS RI, provided by Sun
Microsystems. Because this API is not provided as part of the WebLogic software, it is subject to
change.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 10 - 29
Server-Side Implementation Code
@StreamingAttachment(parseEagerly=true, memoryThreshold=40000L)
@WebService
@MTOM Configure the streaming
public class Streaming { SOAP attachment.
public Streaming(){}
@Oneway Map the
@WebMethod DataHandler.
public void fileUpload(String fileName,
@XmlMimeType("application/octet-stream") DataHandler data) {
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 10 - 30
Client-Side Implementation Code
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 10 - 31
Configuring Streaming SOAP Attachments
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 10 - 32
Configuring Streaming SOAP Attachments (continued)
Configuring Streaming SOAP Attachments on the Client
To configure streaming SOAP attachments on the client, create a StreamingAttachmentFeature
object and pass this as an argument when creating the PortType stub implementation. The following
example sets the directory in which large attachments are stored to /tmp, specifies that streaming
attachments are to be parsed eagerly (immediately rather then on request) and sets the memory
threshold to 4MB. Attachments under 4MB are stored in memory.
import com.sun.xml.ws.developer.StreamingAttachmentFeature;
MTOMFeature mtom = new MTOMFeature();
StreamingAttachmentFeature stf = new
StreamingAttachmentFeature("/tmp", true, 4000000L); // true =
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 10 - 33
Summary
Summary
This slide summarizes what you have learned in this lesson.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 10 - 34
Practice 10 Overview:
Enabling MTOM in JAX-WS Web Services
This practice covers the following topics:
• Enabling an existing Web service to support MTOM
• Extending an existing Web service Java client to use
MTOM
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 10 - 35
Oracle University and Egabi Solutions use only
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
JAX-WS Binding Customization
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Objectives
Objectives
This lesson focuses on describing how the JAXB runtime performs serialization and deserialization
based on the annotations, and how you can use your own annotations to customize the behavior of
the JAXB serialization and deserialization processes.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 11 - 2
JAX-WS and JAXB
JAX-WS:
• Binds Java method signatures and WSDL messages and
operations
– Method name is mapped to port type operation.
– Method parameters are mapped to message parts.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 11 - 3
Data Binding with JAXB
Custom JAXB
Binding Annotations
Declarations
Schema Derived
XML and Existing Java
Unmarshal
HTTP SOAP XML Java Objects
Marshal
JAXB
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 11 - 4
Type Mapping Mechanisms
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 11 - 5
JAXB Binding Scenarios
JAXB schema
generator
XML Java
binding
Schema Classes
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 11 - 6
Quiz
Answer: 3
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 11 - 7
Binding XML Schema to Java Representation
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 11 - 8
Example of XML Schema-to-Java Mapping
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 11 - 9
Mapping Java Types to XML Schema
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 11 - 10
Data Type Mapping
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 11 - 11
Built-in Data Types: XML-to-Java Mapping
boolean boolean
byte byte
double double
float float
int int
integer java.math.BigInteger
long long
Qname javax.xml.namespace.QName
string java.lang.String
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 11 - 12
Built-in Data Types: Java-to-XML Mapping
java.awt.Image base64Binary
java.net.URI string
java.util.Date dateTime
javax.xml.namespace.QName QName
javax.xml.transform.Source base64Binary
short short
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 11 - 13
Supported User-Defined XML Schema Data Types
<xsd:complexType> JavaBean
Derivation of new simple types by Equivalent Java data type of simple type
restriction of an existing simple type
Facets used with restriction element Facets not enforced during serialization
and deserialization
<xsd:anyType> java.lang.Object
<xsd:any> javax.xml.soap.SOAPElement
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 11 - 14
Supported Java User-Defined Data Types
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 11 - 15
Customizing Java-to-XML Using Annotations
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 11 - 16
JAXB Mapping Annotations
Annotation Description
@XmlAccessorType Specifies whether fields or properties are mapped by default.
@XmlRootElement Maps a top-level class to a global element in the XML Schema that
is used by the WSDL of the Web Service.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 11 - 17
Example of JAXB Annotations
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "reservation", propOrder = {
"bookId",
"reservationId",
"username"
})
@XmlElement(namespace = "http://ws.library.com/types”)
protected int bookId;
@XmlElement(namespace = "http://ws.library.com/types”)
protected int reservationId;
@XmlElement(namespace = "http://ws.library.com/types”)
protected String username;
...
}
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 11 - 18
Quiz
Answer: 2
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 11 - 19
Customizing XML Schema-to-Java Mapping Using
Binding Declaration
• Binding declarations can be used to control:
– Specific features, such as asynchrony, wrapper style, and so
on
– JAXB data binding artifacts that are produced by customizing
the XML Schema
• Two ways to define binding declarations:
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 11 - 20
Scopes of Custom Binding Declarations
Global scope
Schema scope
Definition scope
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 11 - 21
Scope of Custom Binding Declarations (continued)
Component scope
Describes customization values that apply to the WSDL or schema element that was annotated.
Scopes for custom binding declarations adhere to the following inheritance and overriding rules:
• Inheritance—Customization values are inherited from the top down. For example, a WSDL
element (JAX-WS) in a component scope inherits a customization value defined in global
scope. A schema element (JAXB) in a component scope inherits a customization value defined
in global, schema, and definition scopes.
• Overriding—Customization values are overridden from the bottom up. For example, a WSDL
element (JAX-WS) in a component scope overrides a customization value defined in global
scope. A schema element (JAXB) in a component scope overrides a customization value
defined in definition, schema, and global scopes.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 11 - 22
Creating an External Binding Declaration File
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 11 - 23
JAX-WS Custom Binding Declarations
Customization Description
Package name Use the jaxws:package binding declaration to define the
package name.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 11 - 24
JAX-WS Custom Binding Declarations
Customization Description
Java parameter name Use the jaxws:parameter binding declaration to
customize the parameter name of generated Java
methods. This declaration can be used to change the
method parameter of a wsdl:operation in a wsdl:portType.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 11 - 25
Example of JAX-WS Custom Binding Declarations
Root of all other
binding declarations
<jaxws:bindings
wsdlLocation="http://localhost:7001/simple/SimpleService?WS
DL"
xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" >
<package name="example.webservices.simple.simpleservice">
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 11 - 26
Creating an External Binding Declarations File
Using JAXB Binding Declarations
• The JAXB binding declarations file is an XML document
that conforms to the XML Schema for the namespace:
http://java.sun.com/xml/ns/jaxb
• The format of the root declaration is as follows:
<jaxb:bindings schemaLocation="uri_of_schema">
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 11 - 27
JAXB Custom Binding Declarations
Customization Description
Global bindings Use the <globalBindings> binding declaration to
define binding declarations with global scope.
You can specify attributes and elements to the
<globalBindings> binding declaration:
• collectionType attribute that specifies a type class
• generateIsSetMethod attribute to generate the
isSet() method corresponding to the getter and setter
Class name Use the <class> binding declaration to define the class
name for a schema element.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 11 - 28
JAXB Custom Binding Declarations
Customization Description
Java property name Use the <property> binding declaration to define the
property name for a schema element.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 11 - 29
Example of JAXB Custom Binding Declarations
<jaxb:bindings schemaLocation="simpleservice.xsd">
<jaxb:bindings node="//xs:simpleType[@name='value1']">
<jaxb:package
name="examples.webservices.simple.simpleservice"/>
</jaxb:bindings>
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 11 - 30
Embedding Binding Declarations
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 11 - 31
Embedding JAX-WS or JAXB Binding
Declarations in the WSDL File
<wsdl:portType name="SimpleServiceImpl">
<jaxws:bindings
xmlns:jaxws="http://java.sun.com/xml/ns/jaxws">
<jaxws:class name="SimpleService"/>
</jaxws:bindings>
</wsdl:portType>
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 11 - 32
Embedding JAXB Binding Declarations in the
XML Schema
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.w3.org/2001/XMLSchema"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
jaxb:version="2.0">
<annotation>
<appinfo>
<jaxb:schemaBindings>
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 11 - 33
Quiz
Answer: 5
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 11 - 34
Summary
Summary
This slide summarizes what you have learned in this lesson.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 11 - 35
Practice 11 Overview:
Customizing JAX-WS Web Services Data Binding
This practice covers the following topics:
• Using JAXB to generate a set of Java classes representing
the schema definition
• Using the schemagen tool to generate schema from
existing Java
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 11 - 36
Implementing JAX-RPC Web Services
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Objectives
Objectives
JAX-WS is the next generation Web services programming model extending the foundation provided
by the JAX-RPC programming model. Both JAX-WS and JAX-RPC programming models and
applications are still supported in WebLogic Server. Note that some features only exist in one style
of Web Service versus the other.. This lesson focuses on the differences between JAX-WS and JAX-
RPC.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 12 - 2
JAX-RPC Versus JAX-WS
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 12 - 3
Standards/Features Supported by JAX-RPC and
JAX-WS
JAX-RPC JAX-WS
SOAP version 1.1 1.1 and 1.2
Asynchronous No Yes
MTOM * No Yes
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 12 - 5
JAX-RPC Server-Side Programming Models
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 12 - 6
JAX-RPC Service Endpoints Run-Time
Architecture
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 12 - 7
JAX-RPC Service Endpoints
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 12 - 8
EJB Endpoints
EJB Endpoints
The J2EE Web service specification defines a new Web service endpoint interface for stateless
session beans that is on a par with the remote and local interfaces already used by enterprise beans.
Unlike the remote and local interfaces already familiar to EJB developers, though, the endpoint
interface does not extend an EJB object type—that is, an EJBObject or EJBLocalObject. Instead, the
endpoint interface extends the javax.ejb.Remote interface directly, which is the same as JSE
endpoint interface. In addition to the endpoint interface, you'll need to define the stateless session
bean that implements the interface.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 12 - 9
Creating a Web Service Using Annotations
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 12 - 10
Creating a JAX-RPC Web Service Using
JDeveloper
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 12 - 11
Quiz
Answer: 2
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 12 - 12
JAX-RPC Client-Side Programming Models
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 12 - 13
Invoking Web Services Using a Generated Stubs
Model
Endpoint
Web Service
Interfaces
WSDL to Java
and Stubs
Mapping Tool
Service (clientgen) WSDL
Interface and Class
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 12 - 14
Endpoint Interface Generated from WSDL
WSDL PortType is
mapped to an interface.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 12 - 15
Generated Stub Class
try {
...
}
}
}
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 12 - 16
Generated Service Interface and Implementation
... Returns
} HelloWorldPort
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 12 - 17
Using the Stub Interface to Access Run-Time
Information
• The javax.xml.rpc.Stub interface enables you to
dynamically configure the Stub instance of your Web
Service client.
• The method of the Stub interface:
– _getProperty()
– _getPropertyNames()
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 12 - 18
WebLogic Web Services Stub Properties
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 12 - 19
Quiz
Answers: 1, 4
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 12 - 20
JAX-RPC Data Binding
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 12 - 21
Mapping XML Schema Complex Types
<types>
<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" targetNamespace="
http://sample.com/jaxrpcsample/BookQuote ">
<complexType name="Book">
<sequence>
<element name="bookId" type="xsd:int" />
<element name="name" type="xsd:string" />
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 12 - 22
Mapping XML Schema Complex Types:
Generated Endpoint Interface
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 12 - 23
Packaging and Deploying JAX-RPC Services
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 12 - 24
Packaging and Deployment Tools
• JDeveloper
• Oracle Enterprise Pack for Eclipse
• Apache Ant: An open tool for automating the software build
process using XML-based build definitions
• WebLogic Ant: jwsc and wldeploy Ant tasks
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 12 - 25
Summary
Summary
This slide summarizes what you have learned in this lesson.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 12 - 26
Practice 12 Overview:
Creating JAX-RPC Web Services
This practice covers the following topics:
• Creating a JAX-RPC-based Web service from an existing
Java class
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED
Oracle Fusion Middleware 11g: Build Web Services 12 - 27
Oracle University and Egabi Solutions use only
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED