Oracle ADF 17 - Developing The Business Tier Web Services

You might also like

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 36

17

Developing the Business Tier with


Web Services

Copyright © 2007, Oracle. All rights reserved.


Objectives

After completing this lesson, you should be able to do


the following:
• Define Service-Oriented Architecture (SOA)
• Describe the benefits of Web services
• Identify Web services components
• Create a Web service
• Utilize a Web service from a client

17-2 Copyright © 2007, Oracle. All rights reserved.


What Is Service-Oriented
Architecture (SOA)?

SOA is a software design pattern that implements a set


of reusable services by using standard elements:

Service
registry
Service
description

Communication protocol

17-3 Copyright © 2007, Oracle. All rights reserved.


SOA: Development Life Cycle

Integrate

Orchestrate
Develop

Secure

Change
Manage
Monitor

17-4 Copyright © 2007, Oracle. All rights reserved.


What Is a Web Service?

A Web service is:


• A software component whose technology is based
on a set of standards for building interoperable
distributed applications
• A set of self-describing business functions
• Service oriented
• Component based

17-5 Copyright © 2007, Oracle. All rights reserved.


Benefits of Web Services

• Distributed component model with interoperability


• XML format for representing data. The request and
response messages are in the XML format.
• Programming language independent
• Easily accessible with standard protocols such as
HTTP, HTTPS, SMTP, and FTP
• Communication through firewalls
• Existing components can be exposed as
Web Services to save development time
• Different communication styles:
– RPC style (synchronous)
– Message style (asynchronous)

17-7 Copyright © 2007, Oracle. All rights reserved.


Web Services and SOA

Web services are a technology that can be used in


SOA:

Service
registry
(UDDI) Service
description
(WSDL)

Communication protocol (SOAP)

17-9 Copyright © 2007, Oracle. All rights reserved.


Web Services Model

Client application 2
Find
XML interface (WSDL)
Web Services
directory
(UDDI)
3 SOAP 1
Invoke Publish

XML interface (WSDL)

Web service

17-10 Copyright © 2007, Oracle. All rights reserved.


Anatomy of a Service

Service Service
interface implementation

New service
Service consumer

Wrapped
legacy

Interface Proxy

Composite
service

17-11 Copyright © 2007, Oracle. All rights reserved.


Defining Web Services

• A Web service is:


– A self-describing business function
– A small application sending data to a Web browser using
Web services
Request

Response
Web browser Web Service

• Web services:
– Refer to a standard set of platform independent
messaging protocols (SOAP, HTTP, JMS)
– Enable connections between services from any
Web-connected device
– Exchange data and functionality in XML format

17-12 Copyright © 2007, Oracle. All rights reserved.


Basic Web Services

Points to
UDDI description
registry WSDL

Describes and
Finds
Points to
service
Web Service

Web Service SOAP Web Service


client (J2EE, PL/SQL,
(J2EE, .NET, .NET,C/C++,
PL/SQL …) Invokes with Legacy …)
XML messages

17-13 Copyright © 2007, Oracle. All rights reserved.


Two Development Use Cases

Bottom-Up Top-Down/Contract Driven

WSDL WSDL

Service Service
implementation implementation

Example: EJB/Java Example: WSDL contract as the


class to WSDL interface and message description

17-14 Copyright © 2007, Oracle. All rights reserved.


JAX-RPC

• Core Web services standard for Java:


– Enables portability across containers
– Standard class and interface structure for client and
server
– Various hook points for custom serializers, custom
handlers, attachments
• Tools must provide abstractions to handle service
as a set of classes.
– Navigator structure for quick location
– Wizard support for declarative definition

17-15 Copyright © 2007, Oracle. All rights reserved.


Simple Object Access Protocol (SOAP)

• Supports RPC or message-oriented information


exchange
• Features:
SOAP header
– Protocol independence
– Language independence
SOAP body
– Platform independence
– Attachments (MIME)
• Message consists of envelope
containing header (optional)
and body

17-16 Copyright © 2007, Oracle. All rights reserved.


Web Services Definition
Language (WSDL)

• Is a definition language to define Web service


interfaces and how to invoke them
• Is an XML Schema for defining Web services:
– Service interface definition: Describes what
message must be sent and what message is
returned
– Service implementation definition: Describes to
which address the message must be sent
• Allows both the messages and the operations on
the messages to be defined abstractly in XML
• Answers three key questions about a Web service:
– What does a service do?
– How is a service accessed?
– Where is a service located?

17-17 Copyright © 2007, Oracle. All rights reserved.


Web Services Definition
Language (WSDL)
<?xml version=“1.0” encoding=“UTF-8” ?>
<definitions name=“Hello” ...
targetNamespace=“http://tempuri.org/Hello.wsdl” ...>
<types>
<schema targetNamespace=“http://tempuri.org/Hello.xsd
...
xmlns:xsd=“http://www.w3.org/2001/XMLSchema” />
</types>
<message name=“sayHelloOutput”>... </message>
<message name=“sayHelloInput”> ... </message>
<portType name=“HelloPortType>
<operation name=“sayHello”> .... </operation>
</portType>
<binding name=“HelloBinding”>
<operation> <input>..</input> <output>..</output>
</operation> </binding>
<service ..> <port> <soap:address location=“..” />
</port>
</service>
</definitions>

17-18 Copyright © 2007, Oracle. All rights reserved.


Anatomy of a WSDL Document

A <portType> A <service>
has a number of describes describes
<operation> with input the <port> and
and output. <soap:address> for a
specific <binding>.

A <message> A <binding>
composed of <types> describes
describes the structure <soap:binding>
of an <operation>. style of an
<operation>.

17-20 Copyright © 2007, Oracle. All rights reserved.


Other Web Service Features

• Run and test


• Deploy
• Use Http Analyzer
• Test for WS-I
compliance
– WSDL
– Running service
• Quality of Service
– Reliability, security
– Auditing, logging

17-21 Copyright © 2007, Oracle. All rights reserved.


Using Http Analyzer

• Sets “dummy” proxy Next/Previous Resend


• Intercepts messages
• Configurable

Headers

17-22 Copyright © 2007, Oracle. All rights reserved.


Why Web Services and Applications?

abstraction
Binding

Facade
UI Business
Generation Service

BPEL Rules
Engine Engine

Client Application server(s) Database

17-23 Copyright © 2007, Oracle. All rights reserved.


UDDI Registry

• Is an online electronic registry for registering


businesses and Web services
• Is a specification for description and discovery
• Supports the Publishing and Inquiry APIs to
publish and
inquire about a
Web service

17-24 Copyright © 2007, Oracle. All rights reserved.


Options for Located Web Service

17-26 Copyright © 2007, Oracle. All rights reserved.


UDDI Publishing and Browsing with
Oracle Enterprise Manager

Using Oracle Enterprise Manager Application Server


Control, you can:
• Browse and register services within the UDDI
registry
• Publish Web services and deploy them to a
Java EE container
• Monitor and administer Web services

17-27 Copyright © 2007, Oracle. All rights reserved.


Oracle Application Server 10g
Web Services
Oracle Application Server
10g Web Services can be
implemented as any of the
following:
• Stateless and stateful
Java classes
• Stateless PL/SQL
packages or Web
services
• Stateless session
Enterprise JavaBeans
(EJBs)
• Java Message Service
(JMS) destinations

17-28 Copyright © 2007, Oracle. All rights reserved.


Developing a Web Service
with a Stateless Java Class

To develop a Web service with a stateless Java class,


perform the following steps:
1. Define an interface.
2. Define a stateless Java class.
3. Generate an .ear file.
4. Deploy the generated .ear file to Oracle
Application Server 10g.

17-29 Copyright © 2007, Oracle. All rights reserved.


Defining an Interface

17-30 Copyright © 2007, Oracle. All rights reserved.


Defining a Stateless Java Class

17-31 Copyright © 2007, Oracle. All rights reserved.


Creating the Web Service

Invoking JDeveloper’s
Create Web Service
Wizard

17-33 Copyright © 2007, Oracle. All rights reserved.


Examining the Web Service Files

17-34 Copyright © 2007, Oracle. All rights reserved.


Deploying the Web Service
Options:
• To embedded OC4J
• Directly to application server
• To WAR or EAR file

17-35 Copyright © 2007, Oracle. All rights reserved.


Web Service Home Page

A Web service home page provides:


• A link to the service definition (WSDL file)
• Links to Web service test pages to test the
available operations of the Web service
• A link to the Web service client-side proxy JAR
• A link to the Web service client-side proxy source

17-36 Copyright © 2007, Oracle. All rights reserved.


Testing the Deployed Web Service
with Home Page

17-37 Copyright © 2007, Oracle. All rights reserved.


Testing the sayHello Operation

17-38 Copyright © 2007, Oracle. All rights reserved.


Exposing and Publishing a PL/SQL
Package as a Web Service

17-39 Copyright © 2007, Oracle. All rights reserved.


Summary

In this lesson, you should have learned how to:


• Describe a Web service in terms of
Service-Oriented Architecture
• Describe that Web services employ a distributed
component model, use XML, and are programming
language independent
• Create, publish, find, and invoke a Web service
• Describe how WSDL is used to define a WS
functionality, how it communicates, and where it is
accessible
• Describe how the UDDI registry supports
publishing and inquiry about Web services

17-40 Copyright © 2007, Oracle. All rights reserved.


Practice Overview:
Creating a Web Service

This practice covers the following topics:


• Developing a Web service
• Consuming a Web service

17-41 Copyright © 2007, Oracle. All rights reserved.

You might also like