Top Banner
1 © Drexel University Software Engineering Research Group (SERG) http://serg.cs.drexel.edu An Introduction to Web Services
27

An Introduction to Web Services - Drexel CCI Introduction to Web Services. 2 © Drexel University Software Engineering Research Group (SERG) Web Services Architecture Web Service

May 28, 2018

Download

Documents

vankien
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: An Introduction to Web Services - Drexel CCI Introduction to Web Services. 2 © Drexel University Software Engineering Research Group (SERG)  Web Services Architecture Web Service

1© Drexel University Software Engineering Research Group (SERG)http://serg.cs.drexel.edu

An Introduction to Web Services

Page 2: An Introduction to Web Services - Drexel CCI Introduction to Web Services. 2 © Drexel University Software Engineering Research Group (SERG)  Web Services Architecture Web Service

2© Drexel University Software Engineering Research Group (SERG)http://serg.cs.drexel.edu

Web Services Architecture

Web ServiceContainer

Protocol-SpecificServer

Client

Web Service

Page 3: An Introduction to Web Services - Drexel CCI Introduction to Web Services. 2 © Drexel University Software Engineering Research Group (SERG)  Web Services Architecture Web Service

3© Drexel University Software Engineering Research Group (SERG)http://serg.cs.drexel.edu

Web Services Architecture

SOAP

ClientProtocol-SpecificServer

Web ServiceContainer

Web Service

SOAP overHTTP/S

Native Call

Page 4: An Introduction to Web Services - Drexel CCI Introduction to Web Services. 2 © Drexel University Software Engineering Research Group (SERG)  Web Services Architecture Web Service

4© Drexel University Software Engineering Research Group (SERG)http://serg.cs.drexel.edu

Web Services Architecture (.Net Scenario)

SOAPWeb ServiceContainer

.Net Framework

ClientWeb Service

orApplication

Client

Protocol-SpecificServer

IISWeb Server

Web Service.asmx

Component

SOAP overHTTP/S

Native Call

Page 5: An Introduction to Web Services - Drexel CCI Introduction to Web Services. 2 © Drexel University Software Engineering Research Group (SERG)  Web Services Architecture Web Service

5© Drexel University Software Engineering Research Group (SERG)http://serg.cs.drexel.edu

Web Services Architecture (Java Scenario)

SOAPWeb ServiceContainer

Apache Axis/SOAP

ClientWeb Service

orApplication

Client

Protocol-SpecificServerApacheTomcat

JSP/ServletContainer Web Service

JavaComponent

SOAP overHTTP/S

Native Call

Page 6: An Introduction to Web Services - Drexel CCI Introduction to Web Services. 2 © Drexel University Software Engineering Research Group (SERG)  Web Services Architecture Web Service

6© Drexel University Software Engineering Research Group (SERG)http://serg.cs.drexel.edu

WSDL – The Contract for Invoking a Service

ClientWeb

ServiceInfrastructure

Web ServiceCall

Web ServiceWSDL

Service Spec.

1. Parse Call2. Validate Call Against WSDL3. Validate Pass?

1. YES: Web Service Implementation2. NO: Generate and Return Fault

Page 7: An Introduction to Web Services - Drexel CCI Introduction to Web Services. 2 © Drexel University Software Engineering Research Group (SERG)  Web Services Architecture Web Service

7© Drexel University Software Engineering Research Group (SERG)http://serg.cs.drexel.edu

WSDL – The Web Service Contract

WSDLMessages

Service InterfaceAbstract Definition

Operations

Interface

BindingService Implementation

Concrete Definition Service

Endpoint

Page 8: An Introduction to Web Services - Drexel CCI Introduction to Web Services. 2 © Drexel University Software Engineering Research Group (SERG)  Web Services Architecture Web Service

8© Drexel University Software Engineering Research Group (SERG)http://serg.cs.drexel.edu

Abstract and Concrete Elements of WSDL

<definitions>

</definitions>

<interface name = “myIFace”>

<message name = “myMsg”>

<types>

</types >. . .

</message >. . .

</interface >. . .

<service><binding name = “Binding1”>

</binding >. . .

</service >

Service Definition WSDL Document

AbstractInterface Definition

ConcreteImplementation

Definition

Page 9: An Introduction to Web Services - Drexel CCI Introduction to Web Services. 2 © Drexel University Software Engineering Research Group (SERG)  Web Services Architecture Web Service

9© Drexel University Software Engineering Research Group (SERG)http://serg.cs.drexel.edu

WSDL Structure

ServiceName = <Service_Name>Ports: Collection of Ports

BindingName = <Binding_Name>Type = <PortType_Interface_Name>Operations: Operation Collection

PortType/InterfaceName = <PortType_Interface_Name>Operations: Operation Collection

MessageName = <Nessage_Name>Parts: Collection of Parts

TypeName = <Message_Type>Simple Built In Type ORComplexType: XSD Definition of Type

1..*

1..*

1..*

1..*

Conc

rete

Ab

stra

ct

MessageType

MessageName

Port/Interface Name

BindingName

PartName = <Part_Name>Type = <Message_Type>

OperationName = <Port_type_op_Namee>Input message= <Message_Name>Output message= <Message_Name>

PortBinding = <Binding_Name>Address: Physical Endpoint

Operation Name

OperationName = <Port_type_op_Name>Input name=Logical_In_Op_NameOutput name=Logical_Out_Op_Name

Page 10: An Introduction to Web Services - Drexel CCI Introduction to Web Services. 2 © Drexel University Software Engineering Research Group (SERG)  Web Services Architecture Web Service

10© Drexel University Software Engineering Research Group (SERG)http://serg.cs.drexel.edu

What is WSDL?Web Service Description LanguageSpecifies

Types: types defined for usage in the messagesMessages: the messages being exchanged between a client and a servicePort types / Interfaces: An abstract set of operations supported by one or more endpoints (commonly known as an interface); operations are defined by an exchange of messagesBindings: concrete protocol and data formats for a specific port typeService: a collection of bound ports and addresses

WSDL allows for the automatic generation of service proxies

Conc

rete

Ab

stra

ct

Page 11: An Introduction to Web Services - Drexel CCI Introduction to Web Services. 2 © Drexel University Software Engineering Research Group (SERG)  Web Services Architecture Web Service

11© Drexel University Software Engineering Research Group (SERG)http://serg.cs.drexel.edu

WSDL TypesThe web services standards define a collection of common types, user-defined types can be specified using XML schema

Example: Array of Strings (“ArrayOf_xsd_string”)<wsdl:types>

<schema targetNamespace="urn:DirectoryService" xmlns=“…"><import namespace="http://schemas.xmlsoap.org/soap/encoding/"/><complexType name="ArrayOf_xsd_string"><complexContent><restriction base="soapenc:Array"><attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:string[]"/></restriction>

</complexContent></complexType></schema>

</wsdl:types>

Page 12: An Introduction to Web Services - Drexel CCI Introduction to Web Services. 2 © Drexel University Software Engineering Research Group (SERG)  Web Services Architecture Web Service

12© Drexel University Software Engineering Research Group (SERG)http://serg.cs.drexel.edu

WSDL MessageEach message to and from a web service is modeled via a <message> tagA given message may have 1 or more partsEach message part has a name and a type

<wsdl:message name="getFilesInDirRequest"><wsdl:part name="in0" type="xsd:string"/>

</wsdl:message>

<wsdl:message name="getFilesInDirResponse"><wsdl:part name="getFilesInDirReturn" type="impl:ArrayOf_xsd_string"/>

</wsdl:message>

Page 13: An Introduction to Web Services - Drexel CCI Introduction to Web Services. 2 © Drexel University Software Engineering Research Group (SERG)  Web Services Architecture Web Service

13© Drexel University Software Engineering Research Group (SERG)http://serg.cs.drexel.edu

WSDL PortType / InterfacePortType elements have been renamed to Interface elementsThese elements associate messages with the operations that they will be used forDefines input, output and fault operations

<wsdl:portType name="DirList2"><wsdl:operation name="getFilesInDir" parameterOrder="in0">

<wsdl:input message="impl:getFilesInDirRequest" name="getFilesInDirRequest"/>

<wsdl:output message="impl:getFilesInDirResponse" name="getFilesInDirResponse"/>

</wsdl:operation></wsdl:portType>

Page 14: An Introduction to Web Services - Drexel CCI Introduction to Web Services. 2 © Drexel University Software Engineering Research Group (SERG)  Web Services Architecture Web Service

14© Drexel University Software Engineering Research Group (SERG)http://serg.cs.drexel.edu

WSDL BindingsBindings provide the concrete syntax that must be used to access operations for different protocols

<wsdl:binding name="DirectoryServiceSoapBinding" type="impl:DirList2"><wsdlsoap:binding style="rpc“ transport="http://..."/><wsdl:operation name="getFilesInDir">

<wsdlsoap:operation soapAction=""/><wsdl:input name="getFilesInDirRequest">

<wsdlsoap:body encodingStyle="http://.../" namespace="urn:DirectoryService" use="encoded"/>

</wsdl:input><wsdl:output name="getFilesInDirResponse">

<wsdlsoap:body encodingStyle=“http://.../" namespace="urn:DirectoryService" use="encoded"/>

</wsdl:output></wsdl:operation>

</wsdl:binding>

Page 15: An Introduction to Web Services - Drexel CCI Introduction to Web Services. 2 © Drexel University Software Engineering Research Group (SERG)  Web Services Architecture Web Service

15© Drexel University Software Engineering Research Group (SERG)http://serg.cs.drexel.edu

WSDL ServicesService elements encapsulate one or more physical ports defining an endpoint for the service

Port definition includes the binding reference

<wsdl:service name="DirList2Service"><wsdl:port binding="impl:DirectoryServiceSoapBinding"

name="DirectoryService"><wsdlsoap:address location=

"http://localhost:8080/axis/services/DirectoryService"/></wsdl:port>

</wsdl:service>

Page 16: An Introduction to Web Services - Drexel CCI Introduction to Web Services. 2 © Drexel University Software Engineering Research Group (SERG)  Web Services Architecture Web Service

16© Drexel University Software Engineering Research Group (SERG)http://serg.cs.drexel.edu

WSDL defines a service contract

ProxyComponent

Stub

i.e., WSDL2JavaWSDL

i.e., Java2WSDLComponentImplementation WSDL

WSDL can be generated from an implementation or be usedto generate a proxy class

Page 17: An Introduction to Web Services - Drexel CCI Introduction to Web Services. 2 © Drexel University Software Engineering Research Group (SERG)  Web Services Architecture Web Service

17© Drexel University Software Engineering Research Group (SERG)http://serg.cs.drexel.edu

WSDL is your Service Contract

Approaches:Contract-FirstContract-LastMeet-in-the-Middle

Page 18: An Introduction to Web Services - Drexel CCI Introduction to Web Services. 2 © Drexel University Software Engineering Research Group (SERG)  Web Services Architecture Web Service

18© Drexel University Software Engineering Research Group (SERG)http://serg.cs.drexel.edu

Contract First

ComponentStubWSDL

ComponentProxy

Advantages: Optimized Interface, Portable InterfaceDisadvantages: Hard to develop

Page 19: An Introduction to Web Services - Drexel CCI Introduction to Web Services. 2 © Drexel University Software Engineering Research Group (SERG)  Web Services Architecture Web Service

19© Drexel University Software Engineering Research Group (SERG)http://serg.cs.drexel.edu

Contract Last

ComponentImplementation WSDL

ProxyComponent

Stub

Advantages: No need to know WSDL, EasyDisadvantages: Non-optimized stubs, portability problems are possible

Page 20: An Introduction to Web Services - Drexel CCI Introduction to Web Services. 2 © Drexel University Software Engineering Research Group (SERG)  Web Services Architecture Web Service

20© Drexel University Software Engineering Research Group (SERG)http://serg.cs.drexel.edu

Meet-In-The Middle

ComponentInterface WSDL

ComponentStub

ComponentProxy

Hand-OptimizedWSDL

Blends the advantages of the contract-first and contract-last approaches

Page 21: An Introduction to Web Services - Drexel CCI Introduction to Web Services. 2 © Drexel University Software Engineering Research Group (SERG)  Web Services Architecture Web Service

21© Drexel University Software Engineering Research Group (SERG)http://serg.cs.drexel.edu

SOAP

SOAP is the web service standard for encoding requests and responses to and from web services

Page 22: An Introduction to Web Services - Drexel CCI Introduction to Web Services. 2 © Drexel University Software Engineering Research Group (SERG)  Web Services Architecture Web Service

22© Drexel University Software Engineering Research Group (SERG)http://serg.cs.drexel.edu

SOAP Structure

SOAP

HeaderLanguage, Security, Schema,etc.

Envelope BodyInput/Output Message

Fault Information

ExtensionsAttachments not governed by SOAP schema

Extensions

Page 23: An Introduction to Web Services - Drexel CCI Introduction to Web Services. 2 © Drexel University Software Engineering Research Group (SERG)  Web Services Architecture Web Service

23© Drexel University Software Engineering Research Group (SERG)http://serg.cs.drexel.edu

The Body Section…

Document-Centric or RPC-CentricDoc-Centric is the .Net default, the body contains an xml representation of the request/responseRPC-Centric is the Java default, the body contains name/value pairs of the arguments in the request/response

Page 24: An Introduction to Web Services - Drexel CCI Introduction to Web Services. 2 © Drexel University Software Engineering Research Group (SERG)  Web Services Architecture Web Service

24© Drexel University Software Engineering Research Group (SERG)http://serg.cs.drexel.edu

SOAP Request - .Net

Page 25: An Introduction to Web Services - Drexel CCI Introduction to Web Services. 2 © Drexel University Software Engineering Research Group (SERG)  Web Services Architecture Web Service

25© Drexel University Software Engineering Research Group (SERG)http://serg.cs.drexel.edu

SOAP Response - .Net

Page 26: An Introduction to Web Services - Drexel CCI Introduction to Web Services. 2 © Drexel University Software Engineering Research Group (SERG)  Web Services Architecture Web Service

26© Drexel University Software Engineering Research Group (SERG)http://serg.cs.drexel.edu

SOAP Request – Axis/Java (RPC-Centric)

Page 27: An Introduction to Web Services - Drexel CCI Introduction to Web Services. 2 © Drexel University Software Engineering Research Group (SERG)  Web Services Architecture Web Service

27© Drexel University Software Engineering Research Group (SERG)http://serg.cs.drexel.edu

SOAP Response – Axis/Java (RPC-Centric)