You are on page 1of 30

15

Using Web Services with ADF Applications

Copyright © 2006, Oracle. All rights reserved.


Objectives

After completing this lesson, you should be able to:


• Explain the basics of SOA and Web services
• Define Web service components
• Create a simple Web service and utilize it from a
test client
• Call a Web service from an ADF-BC application
• Expose an ADF-BC application module as a Web
service

15-2 Copyright © 2006, Oracle. All rights reserved.


Course Road Map
3 ADF Faces
Overview

Simple Master- Transactions Passing Events


Page Detail Values
9 10 11 12 13
14
Overview 2 JSF Controller 13

Deployment
8 ADF Model

4 Business Services
Overview

Entity View Application Web


Objects Objects Modules Services
5 6 7 15

15-3 Copyright © 2006, Oracle. All rights reserved.


What Is Service-Oriented Architecture?

Service-Oriented Architecture (SOA) is:


• An architectural style for integrating loosely coupled
interacting software services
• A set of components (services) that can be invoked
• Enabled through a set of standards

Service request
Service Service
consumer provider
Service response

15-4 Copyright © 2006, Oracle. All rights reserved.


Service-Oriented Architecture
Development Life Cycle

Integrate

Orchestrate
Develop

Secure

Change
Manage
Monitor

15-5 Copyright © 2006, Oracle. All rights reserved.


What Are Services?

A service:
• Represents a unit of work invoked as part of a
business process
• Communicates with clients through standard
protocols and technologies
• Performs a business function (such as, validate credit
card) and can be
– A subset of an EIS system implementation
– A part of an application module
– A Web service implementation

15-6 Copyright © 2006, Oracle. All rights reserved.


Anatomy of a Service

Service Service
interface implementation

New service
Service consumer

Wrapped
legacy

Interface Proxy

Composite
service

15-7 Copyright © 2006, 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:
– Refers to a standard set of platform independent
messaging protocols (SOAP, HTTP, JMS)
– Allows connections between services from any Web-
connected device
– Exchanges data and functionality in XML format

15-8 Copyright © 2006, 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

15-9 Copyright © 2006, Oracle. All rights reserved.


Two Development Use Cases

Bottom-Up Top-Down/Contract Driven

WSDL WSDL

Service Service
Implementation Implementation

Example: EJB/Java class Example: WSDL contract as the


to WSDL interface and message description

15-10 Copyright © 2006, 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 set of classes.
– Navigator structure for quick location
– Wizard support for declarative definition

15-11 Copyright © 2006, Oracle. All rights reserved.


Web Services Interoperability

• Web services interoperability


– Develops profiles
– Suggests best practices
– Provides testing tools
• Run-time and tools
uptake
– Oracle JDeveloper
analysis
– OracleAS compliance

15-12 Copyright © 2006, Oracle. All rights reserved.


Create Web Services in JDeveloper

• Create JAX-RPC Web services (bottom-up).


• Create Web service proxy from WSDL or endpoint.
• Generate Java implementation from WSDL
(top-down).

15-13 Copyright © 2006, Oracle. All rights reserved.


Creating a Bottom-Up
JAX-RPC Web Service

Wizard based
• Select the type of the underlying implementation
from the Web Services New Gallery.
• Select the SOAP message format.

15-14 Copyright © 2006, Oracle. All rights reserved.


Choosing SOAP Message Format

• Document/literal
– Single argument in a method
– Data passed as XML document
– Used by BPEL Web services
<element name="creditRatingElement“ type="string" nillable="true"/>

• Document/wrapped: multiple arguments


<complexType name="creditRating">
<sequence>
<element name="pSsn" type="string" nillable="true"/>
</sequence>
</complexType>
<element name="creditRatingElement" type="tns:creditRating"/>

• RPC: literal or encoded


15-15 Copyright © 2006, 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>.

15-17 Copyright © 2006, 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

15-18 Copyright © 2006, Oracle. All rights reserved.


Using Http Analyzer

• Sets “dummy” proxy Next/Previous Resend


• Intercepts messages
• Configurable

Headers

15-19 Copyright © 2006, Oracle. All rights reserved.


Why Web Services and Applications?

Abstraction
Binding

Façade
UI Business
Generation Service

BPEL Rules
Engine Engine

Client Application Server(s) Database

15-20 Copyright © 2006, Oracle. All rights reserved.


Publishing an Application Module as a
Web Service

1. Develop custom methods in the <app>Impl.java.


2. Expose in the Client Interface.

15-21 Copyright © 2006, Oracle. All rights reserved.


Calling a Web Service from an
Application Module

1. Set the application module as Remoteable.


2. Choose the J2EE Web Services configuration.

All publishable
methods in the
client interface
become
operations in the
generated
service.

15-22 Copyright © 2006, Oracle. All rights reserved.


Were All the Methods Published?

15-23 Copyright © 2006, Oracle. All rights reserved.


Changing the SOAP Message Format

1. Delete the <wrapped-element/> from the mapping


file.
2. Use the Editor to change the format to Doc/Literal.

15-25 Copyright © 2006, Oracle. All rights reserved.


Editing the Generated Web Service

1. Change the message format.


2. Add any custom serializers/mappings.
3. Add WSIF binding, handlers…

15-26 Copyright © 2006, Oracle. All rights reserved.


Creating Web Service Data Controls

• Context menu for Web Service, WSDL, Proxy:


– Create data control
• New gallery
– URL Services
– Web Service

15-27 Copyright © 2006, Oracle. All rights reserved.


Viewing the Web Service Data Control

Method
public String setRequestStatusClosed(int requestid)

WSDL Extract
……
<element name="setRequestStatusClosedElement" type="int"/>
<element name="setRequestStatusClosedResponseElement" type="string"

nillable="true"/>
……..
<operation name="setRequestStatusClosed">
……

15-28 Copyright © 2006, Oracle. All rights reserved.


Creating the ADF Data Bindings

Methods

Parameters

Return Values

15-29 Copyright © 2006, Oracle. All rights reserved.


Calling a Web Service Programmatically

1. Create a project for client


proxy.
– Generate a Web
Service proxy.
2. In Application Module:
1. Create method to
call proxy.
2. Instantiate generated proxy class,
<webservicename>SoapHttpPortClient.java.
3. Invoke Web Service method on class.
BPEL process invoked like any other Web Service:
– Use BPEL WSDL to generate proxy.
– Synchronous/asynchronous invocation options.

15-30 Copyright © 2006, Oracle. All rights reserved.


Practice 15: Overview

This practice covers the following topics:


• Creating a custom method and expose to client
interface
• Creating a page to call the method
• Exposing the method as a Web Service
• Creating a proxy to run the service
• Using the Http Analyzer to test the service
• Calling the service from a page

15-32 Copyright © 2006, Oracle. All rights reserved.


Summary

In this lesson, you should have learned how to:


• Describe a Web Service in terms of the service-
oriented architecture
• Explain how 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

15-33 Copyright © 2006, Oracle. All rights reserved.

You might also like