55
Providing and Consuming Web Services in ABAP Peter McNulty SAP NetWeaver Product Management

ABAP - Web Service - Providing and Consuming

Embed Size (px)

Citation preview

Page 1: ABAP - Web Service - Providing and Consuming

Providing and Consuming Web Services in ABAP

Peter McNultySAP NetWeaver Product Management

Page 2: ABAP - Web Service - Providing and Consuming

© SAP AG 2005, SAP TechEd ’05 / CD153 / 2

Agenda

Overview of the Web Service technology

Inside-out approach: Creating a Web Service from existing business functionality

Demo: Create a Web Service

Consuming a Web Service from an ABAP program

Demo: Consume a Web Service

Summary

Page 3: ABAP - Web Service - Providing and Consuming

© SAP AG 2005, SAP TechEd ’05 / CD153 / 3

Agenda

Overview of the Web Service technology

Inside-out approach: Creating a Web Service from existing business functionality

Demo: Create a Web Service

Consuming a Web Service from an ABAP program

Demo: Consume a Web Service

Summary

Page 4: ABAP - Web Service - Providing and Consuming

© SAP AG 2005, SAP TechEd ’05 / CD153 / 4

Web Services Overview: Definition

WEB SERVICES are

SELF CONTAINED

and SELF DESCRIBING

APPLICATION FUNCTIONALITIES

that can be

PROCESSED

through

OPEN INTERNET STANDARDS

Page 5: ABAP - Web Service - Providing and Consuming

© SAP AG 2005, SAP TechEd ’05 / CD153 / 5

Web Services Overview: The Nature of Web Services

Web Services

act like a black-box that may require input and deliver a result

work on top of any communication technology stack

can be published, discovered and invoked based on open technology standards

work in synchronous and asynchronous scenarios

facilitate integration within an enterprise as well as cross enterprises

Page 6: ABAP - Web Service - Providing and Consuming

© SAP AG 2005, SAP TechEd ’05 / CD153 / 6

Web serviceClient

Web Services Overview: The Paradigm

UDDIUDDIService Directory

SOAP

WSDLDocument

Web service Provider

Bus. FunctionalityW

eb s

ervi

ce

WSDLDocument

Create Web serviceCreate WSDLPublish WSDL (opt.)

1Discover Web serviceDevelop Client App

2

Web service Execution

3

Direct WSDL exchange

Page 7: ABAP - Web Service - Providing and Consuming

© SAP AG 2005, SAP TechEd ’05 / CD153 / 7

Web Services Overview: Examples

Intelligent product catalog search

Product availability check

Pricing inquiry

Customer credit check

Order status check

Vendor managed inventory Demand forecasts, stock replenishment …

Dynamic auctioning and bidding

Publish and analyze financial reports (XBRL based)

Electronic bill presentment and payment

Matching vacancies and job applicants profiles

Postal service address check

UDDI registration and discovery

Automated web searches (Google)

Page 8: ABAP - Web Service - Providing and Consuming

© SAP AG 2005, SAP TechEd ’05 / CD153 / 8

HR

Web Services Overview: Example Get Employee Address Info

PortaliView

GetEmployee Address

Information

Private Address

Archiving Database

= Web Service

Manager Company Service Provider

CRM

Employee Contact

Information

Page 9: ABAP - Web Service - Providing and Consuming

© SAP AG 2005, SAP TechEd ’05 / CD153 / 9

Web Services Overview: Fundamental Elements of the complete Web Service Solution

Web ServiceTechnology

Open Technology Standards for Web

Services Referent

to business semantics

SAP NetWeaver

RosettaNet,Spec2000,HR-XML,

XBRL, IFX,papiNet,

....

XML, WSDL, SOAP, UDDI, WSI

Page 10: ABAP - Web Service - Providing and Consuming

© SAP AG 2005, SAP TechEd ’05 / CD153 / 10

Web Services Overview: Standards – Overview

SAP NetWeaver is based on Open Standards

SAP NetWeaver Supports Standards on Technology, Framework and Business Level

Built on a consistent technology and application stack

Examples for Supported Standards in SAP NetWeaver

W3CSOAP 1.1WSDL 1.1XML SchemaXML SignatureXSL

BPMLCIMOASIS

SAMLUBLUDDI 2.0 / 3.0WSRPWS-SecurityXML.org

Wf-XMLWS-I

Basic Profile 1.0XMLAUDDI4JJAX-RPCJAXM… and many others

Page 11: ABAP - Web Service - Providing and Consuming

© SAP AG 2005, SAP TechEd ’05 / CD153 / 11

Web Services Overview: Standards – UDDI

Describes how to advertise and discover a Web serviceDifferentiates Web service provider, Web service and Webservice typeHolds metadata that can be used to search for services(names, IDs, categories, types, etc.)Specifies the interface for Web service registries

UDDI Business RegistryTHE directory for Web services on the InternetPublicly available, free of chargeOperated by SAP, IBM, Microsoft, and NTT CommunicationsUDDI Version 3 Beta available nowSAP’s node at http://uddi.sap.com

Universal Description, Discovery and Integration (UDDI)

Page 12: ABAP - Web Service - Providing and Consuming

© SAP AG 2005, SAP TechEd ’05 / CD153 / 12

Web Services Overview: Standards – WSDL Overview

Describes the basic characteristics of a Web serviceSupported operations and their data format e.g. xCBL OrderSupported protocols e.g. SOAPNetwork address e.g. http://a.com/order

Further informationWorking Group: http://www.w3.org/2002/ws/desc/Specification: http://www.w3.org/TR/wsdl12/

Web Service Description Language

Page 13: ABAP - Web Service - Providing and Consuming

© SAP AG 2005, SAP TechEd ’05 / CD153 / 13

WSDL Document Structure

<definitions>

<types>

The data types used by the web service

</types>

<message>

The messages used by the web service

</message>

<portType>

The operations performed by the web service

</portType>

<binding>

The communication protocols used by the web service

</binding>

</definitions>

Page 14: ABAP - Web Service - Providing and Consuming

© SAP AG 2005, SAP TechEd ’05 / CD153 / 14

WSDL Types Element

Defines the data types used by the web service

XML Schema Definition Language

Page 15: ABAP - Web Service - Providing and Consuming

© SAP AG 2005, SAP TechEd ’05 / CD153 / 15

WSDL Message Element

Defines the data elements of an operation

Page 16: ABAP - Web Service - Providing and Consuming

© SAP AG 2005, SAP TechEd ’05 / CD153 / 16

WSDL portType Element

Defines the supported operations that can be performed and the messages that are involved.

This is an example of a request-response operation

Page 17: ABAP - Web Service - Providing and Consuming

© SAP AG 2005, SAP TechEd ’05 / CD153 / 17

WSDL Bindings Element

Defines the message format and protocol details for a web serviceThe soap:binding element has two attributes. In this example …

style attribute is document transport attribute defines the SOAP protocol to use HTTP

The operation element defines each operation that the port exposes.input and output operations are encoded as "literal”

Page 18: ABAP - Web Service - Providing and Consuming

© SAP AG 2005, SAP TechEd ’05 / CD153 / 18

WSDL Service Element

Defines the set of ports supported by the web serviceFor each supported protocol there will be one port element

Page 19: ABAP - Web Service - Providing and Consuming

© SAP AG 2005, SAP TechEd ’05 / CD153 / 19

HTTP, SMTP, …

Protocol specific data(e.g. quality of service)

Application-specific data

Type system

SOAPTransport Binding

Web Services Overview: Standards – SOAP Structure and Features

Message Format

Header

Body

Application Data

Page 20: ABAP - Web Service - Providing and Consuming

© SAP AG 2005, SAP TechEd ’05 / CD153 / 20

Web Services Overview: Standards – SOAP Example

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>

< SOAP-ENV:Envelopexmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SAP="http://sap.com/xi/XI/Message/30">

<SOAP-ENV:Body ><pns:getEmployeePersonalAddressxmlns:pns="urn:AddressWSVi">

<employeeID >1001</employeeID> <addressType>HM</addressType> <actualDate >2005-08-22</actualDate>

</pns:getEmployeePersonalAddress></SOAP-ENV:Body >

</SOAP-ENV:Envelope >

Page 21: ABAP - Web Service - Providing and Consuming

© SAP AG 2005, SAP TechEd ’05 / CD153 / 21

Web Services Overview: Standards –Web Services Interoperability Organization (WS-I)

“Accelerating the adoption of Web services by reducing the cost associated with standards adoption”

Focus on Web service interoperabilitySelect, integrate and profile existing industry standardsProvide implementation guidance and tools

DeliverablesProfiles specify conformance requirements for Web servicesTesting Tools can be used to test profile conformanceSample Applications demonstrate interoperable implementations

WS-I Basic Profile 1.0Industry’s common denominator for Web service applicationsCovers HTTP, XML, XML Schema, SOAP, WSDL, and UDDIFinalized August 12, 2003

Page 22: ABAP - Web Service - Providing and Consuming

© SAP AG 2005, SAP TechEd ’05 / CD153 / 22

Web Services Technology Overview: Providing Web Services based on Open Standards

Stan

dard

Inte

rfac

es

Virt

ual I

nter

face

Bus

ines

s A

pplic

atio

nIDOC

BAPI

RFC

EJB

Java Class

XI Server Proxy

Web serviceRuntime

Web serviceMeta Data

SAP Web Application Server

WSClient … ……

UDDIUDDIRegistry

SOAP

WSDL

Web

ser

vice

Development Environments

ABAP Java

Page 23: ABAP - Web Service - Providing and Consuming

© SAP AG 2005, SAP TechEd ’05 / CD153 / 23

Web

ser

vice

Prox

y

Web Services Technology Overview: Consuming Web Services based on Open Standards

Web

ser

vice

Clie

nt

App

licat

ion

Web serviceRuntime

Web serviceMeta Data

SAP Web Application Server

UDDIUDDIRegistry

SOAP

WSDL

Web service Provider

Bus. FunctionalityWeb

ser

vice

Development Environments

ABAP Java

Page 24: ABAP - Web Service - Providing and Consuming

© SAP AG 2005, SAP TechEd ’05 / CD153 / 24

Web serviceClient

Web Services Technology Overview: Value Added Web Services with XI

Web serviceClient

SAP Web AS≥ 6.40

SOAP

SAP XIIntegration Server

Point-to-Point“Basic” Web services

“Mediated”Web serviceswith Routing,

Mapping and BPM

SOAP

XI Protocolor SOAP

SAP System

3rd Party

Adapter

Adapter

Page 25: ABAP - Web Service - Providing and Consuming

© SAP AG 2005, SAP TechEd ’05 / CD153 / 25

Agenda

Overview of the Web Service technology

Inside-out approach: Creating a Web Service from existing business functionality

Demo: Create a Web Service

Consuming a Web Service from an ABAP program

Demo: Consume a Web Service

Summary

Page 26: ABAP - Web Service - Providing and Consuming

© SAP AG 2005, SAP TechEd ’05 / CD153 / 26

Inside-OutStart of implementation in the backend systemInterface semantics pre-defined and reflects directly implementationDrawback: Implementation details are visible in the interface

Outside-InCentral design of interfaces that make business sense in SAP XI Integration RepositoryUsing global data typesReference to Governance Process for PICGeneration of proxies from abstractly modeled interfaceImplementation of “glue code” between proxy and business functionImplementation can be changed without changes in interface

Two basic Ways of Developing an Interface

Page 27: ABAP - Web Service - Providing and Consuming

© SAP AG 2005, SAP TechEd ’05 / CD153 / 27

Creating a Web Service in less than ONE Minute

1No Web service specific programmingNew or existing applicationsDefines standard interfacesWell known programming models

2Wizard based approachBased on preconfigured profilesBased on abstract behaviorAvailable for ABAP & Java

3Deployment in JavaActivation in ABAP

Activate /Deploy Web Service

GenerateWeb Service

Implement Business Application

WS Configuration

WS Variant /Definition *

Service/VirtualInterface*

*Note: The terms Service Interface and Variant refer to the ABAP 7.0 implementation They correlate to Virtual Interface and WS Definition on the Java stack and ABAP 6.40 release.

Page 28: ABAP - Web Service - Providing and Consuming

© SAP AG 2005, SAP TechEd ’05 / CD153 / 28

The Web Service Creation Wizard – Background

Out-of-the-box Web services enablement of SAP solutions

Allows to expose an existing endpoint as a Web Service with a few mouse-clicks

Only shows the most important settings in the wizardDefault values (profiles) for other settings

Hides technical details

Implicitly creates all necessary objects

ABAP Web Service Wizard transaction: WS_WZD_START

Page 29: ABAP - Web Service - Providing and Consuming

© SAP AG 2005, SAP TechEd ’05 / CD153 / 29

Demo – Web Service Creation Wizard

Demo

Page 30: ABAP - Web Service - Providing and Consuming

© SAP AG 2005, SAP TechEd ’05 / CD153 / 30

Demo – Web Service Creation Wizard

Enter a name of the Service Definition and select the endpoint type.

Page 31: ABAP - Web Service - Providing and Consuming

© SAP AG 2005, SAP TechEd ’05 / CD153 / 31

Demo – Web Service Creation Wizard

Select the Function Module

Page 32: ABAP - Web Service - Providing and Consuming

© SAP AG 2005, SAP TechEd ’05 / CD153 / 32

Demo – Web Service Creation Wizard

Choose authorization profile and release the Web service

Page 33: ABAP - Web Service - Providing and Consuming

© SAP AG 2005, SAP TechEd ’05 / CD153 / 33

The Web Service Homepage …

… is available for each deployed Web Service

… shows the documentation for the Web Service

… allows to retrieve WSDL descriptions in different styles

… offers testing capabilities

… can be used to test SAP and non-SAP Web services

… is a JSP page which requires the Java stack to be installed

Page 34: ABAP - Web Service - Providing and Consuming

© SAP AG 2005, SAP TechEd ’05 / CD153 / 34

Demo – Web Service Homepage

Demo

Page 35: ABAP - Web Service - Providing and Consuming

© SAP AG 2005, SAP TechEd ’05 / CD153 / 35

Demo – Web Service Homepage

Overview page

Page 36: ABAP - Web Service - Providing and Consuming

© SAP AG 2005, SAP TechEd ’05 / CD153 / 36

Demo – Web Service Homepage

Result of the Web service test.

Page 37: ABAP - Web Service - Providing and Consuming

© SAP AG 2005, SAP TechEd ’05 / CD153 / 37

Creating a Web Service Step-by-Step

The Step-by-Step approachCreate all objects by hand

Full flexibility and options

More expenses

… but still configuration only

Page 38: ABAP - Web Service - Providing and Consuming

© SAP AG 2005, SAP TechEd ’05 / CD153 / 38

Web Service Interface – Background

The Service Interface is the interface visible to clients

(via WSDL, UDDI,…)

A Service Interface …

… provides abstraction from concrete implementation (=endpoint)

… allows to publish a “view” on existing implementations as Web Service Interfacesi.e. renaming, hiding of parameters/methods, default values

… allows to define how the Web Service Interface is represented in the SOAP message

Note: The term Service Interface refers to the ABAP 7.0 implementation. It correlates to a Virtual Interface on the Java stack and ABAP 6.40 releases.

Page 39: ABAP - Web Service - Providing and Consuming

© SAP AG 2005, SAP TechEd ’05 / CD153 / 39

Web Service Interface – Background

VirtualInterface

ImplementationLayer

i_employeeID (I)

i_address_type(I)

e_street(O)

getEmployeePrivateAddress

e_city(O)

e_county(O)

e_country(O)

<SOAP-ENV:Envelope><SOAP-ENV:Body>

<ns1:getHomeAddress><ns1:Employee>1001</ns1:Employee>

</ns1:getHomeAddress></SOAP-ENV:Body>

</SOAP-ENV:Envelope>

<SOAP-ENV:Envelope><SOAP-ENV:Body>

<rpl:getHomeAddressResponse><rpl:Response>

<tns:street>10 Main Street</tns:street><tns:city>Ottawa</tns:city><tns:province>Ontario</tns:province><tns:country>CAN</tns:country>

</rpl:Response></rpl:getHomeAddressResponse>

</SOAP-ENV:Body></SOAP-ENV:Envelope>

street (O)

city (O)

province (O)

country(O)

getHomeAddress

Request

Employee (I)

Response

Rename methods

Rename parameters

Default ValueHM

Provide default values and hide parameters

Page 40: ABAP - Web Service - Providing and Consuming

© SAP AG 2005, SAP TechEd ’05 / CD153 / 40

Demo – Web Service / Virtual Interface

Demo

Page 41: ABAP - Web Service - Providing and Consuming

© SAP AG 2005, SAP TechEd ’05 / CD153 / 41

Demo – Web Service Interface

Page 42: ABAP - Web Service - Providing and Consuming

© SAP AG 2005, SAP TechEd ’05 / CD153 / 42

Web Service Variant / Definition *

A Web service Variant / Definition is the assignment of behavior to a Web Service

Interface via features

MotivationA Web service is not only described by its interface but also by its behavior with respect to

stateless/stateful communication, transactional behavior, security requirements, …

Ideadescribe this kind of behavior via abstract featuresleave it to the Web Service Configurator to assign technical protocols to these abstract featuresExample:

Feature: StatefulTechnical Protocols: Stateful via HTTP-Cookies,

Stateful via URL-Extensions

Note: The term Web Service Variant refers to the ABAP 7.0 implementation. It correlates to a Web Service Definition on the Java stack and ABAP 6.40 releases.

Page 43: ABAP - Web Service - Providing and Consuming

© SAP AG 2005, SAP TechEd ’05 / CD153 / 43

Web Service Variant / Definition

BenefitsThe same Web Service Variant / Definition can be deployed to various application servers which may differ in their technical capabilities

Web Service Client implementations do not depend on technical server information

Clients are generated based on implementation-independent Web Service variants / definitionsTechnical details are configured separately in the Web Service Client Runtime

Page 44: ABAP - Web Service - Providing and Consuming

© SAP AG 2005, SAP TechEd ’05 / CD153 / 44

Demo – Web Service Variant / Definition

Demo

Page 45: ABAP - Web Service - Providing and Consuming

© SAP AG 2005, SAP TechEd ’05 / CD153 / 45

Demo – Web Service Variant / Definition

Page 46: ABAP - Web Service - Providing and Consuming

© SAP AG 2005, SAP TechEd ’05 / CD153 / 46

Web Service Configuration & Deployment

A Web Service Configuration is the assignment of technical

protocols to abstract features

Based on the Web Service capabilities of the specific SAP Web Application Server

Configuration of additional Web Service Runtime featuresLogging, Tracing, MonitoringSecurity Roles…

Deployment as usualSDM deployment in Java

Page 47: ABAP - Web Service - Providing and Consuming

© SAP AG 2005, SAP TechEd ’05 / CD153 / 47

Demo – Web Service Configuration

Demo

Page 48: ABAP - Web Service - Providing and Consuming

© SAP AG 2005, SAP TechEd ’05 / CD153 / 48

Demo – Web Service Configuration

Page 49: ABAP - Web Service - Providing and Consuming

© SAP AG 2005, SAP TechEd ’05 / CD153 / 49

Agenda

Overview of the Web Service technology

Inside-out approach: Creating a Web Service from existing business functionality

Demo: Create a Web Service

Consuming a Web Service from an ABAP program

Demo: Consume a Web Service

Summary

Page 50: ABAP - Web Service - Providing and Consuming

© SAP AG 2005, SAP TechEd ’05 / CD153 / 50

Creating a Web Service Client Application

1From UDDIVia URL (from server)From local ServerFrom File SystemFrom XI repository

2Environment specificAvailable for ABAP & Java

3Focus on Business ApplicationSOAP / XML handling hidden by proxy

DevClient Application

elop

GenerateWeb Service Proxy

Retrieve WSDL

Page 51: ABAP - Web Service - Providing and Consuming

© SAP AG 2005, SAP TechEd ’05 / CD153 / 51

Demo – Creating a Web Service Client

Demo

Page 52: ABAP - Web Service - Providing and Consuming

© SAP AG 2005, SAP TechEd ’05 / CD153 / 52

Demo – Creating a Web Service Client

Create Proxy Object

Page 53: ABAP - Web Service - Providing and Consuming

© SAP AG 2005, SAP TechEd ’05 / CD153 / 53

Agenda

Overview of the Web Service technology

Inside-out approach: Creating a Web Service from existing business functionality

Demo: Create a Web Service

Consuming a Web Service from an ABAP program

Demo: Consume a Web Service

Summary

Page 54: ABAP - Web Service - Providing and Consuming

© SAP AG 2005, SAP TechEd ’05 / CD153 / 54

Summary

The Enterprise Service Architecture (ESA), SAP’s approach for building services-oriented business applications utilizes Web Services as vital part of its communication and integration strategy

SAP’s rich business functionality, in conjunction withstate-of-the-art technology, enables you to establish cross-company business processes as an integrated part of your development efforts based on Web Services

SAP NetWeaver Application Server offers an easy, convenient way to build Web services

Page 55: ABAP - Web Service - Providing and Consuming

© SAP AG 2005, SAP TechEd ’05 / CD153 / 55

Q&A

Questions?