View
43
Download
0
Category
Tags:
Preview:
DESCRIPTION
Web Services. Index Overview SOAP WSDL UDDI Performance. basado en UPC-DAC/FIB-AAD Jordi Torres; v 2 .0 -05/04. Web Services. What are web services? Web services are modular web applications that provide data and services to other applications over the web - PowerPoint PPT Presentation
Citation preview
1
Web Services
Index- Overview
- SOAP- WSDL- UDDI- Performance
basado en UPC-DAC/FIB-AAD Jordi Torres; v2.0-05/04
2
Web Services
What are web services? - Web services are modular web applications that
provide data and services to other applications over the web
- Web services apply web technologies such as HTTP and XML to the concepts of distributed computing technologies such as CORBA and DCOM
- Aplicaciones auto-contenidas, auto-escritas que pueden ser publicadas, localizadas e invocadas a través de la Web
3
Web Service Examples
A stock quote service. A weather service, a map service, a web
search service… - any composition of Web services.
e.g. Dollar Rent-A-Car- Create standard interfaces so business
partners could tap into the company's car reservation system.
Google, Amazon, …http://www.google.com/apis/
4
What are Web Services? Today’s web:
- Web designed for application to human interactions• Information sharing: a distributed content library. • Built on very few standards: http + html• Shallow interaction model: very few assumptions
made about computing platforms.- Enabled B2C e-commerce.- Non-automated B2B interactions.
“Web services” is an effort to build a distributed computing platform for the Web.- Services available via the Web.- Meant mainly for application to application
communication (as opposed to users directly)Enables Business-to-Business transactions.
- E.g., a web service is contacted on a URL using the SOAP protocol over HTTP.
5
Complete picture of distributed applications
(using WS)
6
Core technologies used for WS
XML SOAP
- Simple Object Access Protocol - a framework for exchanging XML-based information in a
network - the currently most hyped XML/Web service technology
WSDL - Web Service Description Language - an XML-based language for describing network services - WSDL descriptions of capabilities and locations of services - like an interface description language for Web services - communication using SOAP or direct HTTP
UDDI - Universal Description, Discovery, and Integration- provides a registry mechanism for clients and servers to
find each other - uses SOAP for communication
7
Otra definición
Programas accesibles en Internet que exponen su funcionalidad recibiendo/enviando mensajes SOAP a través de HTTP(s) y describen su interfaz en WSDL
8
The Web Services Stack
ServicePublication/Discovery
ServicePublication/Discovery
ServiceDescription
ServiceDescription
XML MessagingXML Messaging
Transport NetworkTransport Network
UDDI
WSDL
SOAP
HTTP, SMTP, MQSeries, etc.
9
10
What is SOAP?
SOAP is a lightweight protocol for exchange of information in a decentralized, distributed environment using XML.
11
The Simple Object Access Protocol (SOAP)
XML-based protocol for messaging and
RPC
- Can works on top of existing transports
• HTTP, SMTP, FTP, MQSeries
Use of XML schema for encoding typed
values
Language independent
- Generation of SOAP messages available in
popular programming language
• C, Java, Perl
12
SOAP: FORMATO GENERAL
Envelope
Body
HeaderHeader Key
Header Key
13
SOAP: Formato general
SOAP especifica el formato de mensajes
Envelope: datos globales (codificación, espacio de nombres, ...)contiene: header (opcional) + body (obligatorio)
Body:contiene datos en formato XMLHeader: contiene meta-informaticón
14
Sample HTTP Interaction
(C) Prof. Dr. Frank Leymann, IBM
15
HTTP POST: Invoking Code
(C) Prof. Dr. Frank Leymann, IBM
16
A Simple SOAP RPC( SOAP Message Embedded in HTTP Request)
POST /StockQuote HTTP/1.1Host: www.stockquoteserver.comContent-Type: text/xml; charset="utf-8"Content-Length: nnnnSOAPAction: "Some-URI"
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <SOAP-ENV:Body> <m:GetLastTradePrice xmlns:m="Some-URI"> <symbol>DIS</symbol> </m:GetLastTradePrice> </SOAP-ENV:Body></SOAP-ENV:Envelope>
Object Endpoint
Method nameInput parameter
17
A simple soap response( SOAP Message Embedded in HTTP Response)
HTTP/1.1 200 OKContent-Type: text/xml; charset="utf-8"Content-Length: nnnn
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> <SOAP-ENV:Body> <m:GetLastTradePriceResponse xmlns:m="Some-URI"> <Price>34.5</Price> </m:GetLastTradePriceResponse> </SOAP-ENV:Body></SOAP-ENV:Envelope>
18
(three) standard aspects of SOAP
Overall message format A SOAP message is an envelope containing
zero or more headers and exactly one body.
The SOAP encoding rules defines a serialization mechanism that can be used to exchange instances of application-defined datatypes. ( based on XSD)
The SOAP RPC representation defines a convention that can be used (optional) to represent remote procedure calls and responses (if not, message-oriented style)
19
Working example: A soap request
POST /servlet/rpcrouter HTTP/1.1
Host: www.messages.com
Content-Type: text/xml; charset="utf-8"
Content-Length: nnnn
SOAPAction: ""
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
<SOAP-ENV:Body>
<ns1:getMessage xmlns:ns1="urn:NextMessage"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<UserID xsi:type="xsd:string">JDoe</UserID>
<Password xsi:type="xsd:string">0JDOE0</Password>
</ns1:getMessage>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
20
Working example: soap response
HTTP/1.1 200 OK
Content-Type: text/xml; charset="utf-8"
Content-Length: nnnn
<SOAP-ENV:Envelope>
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
<SOAP-ENV:Body>
<ns1:getMessage xmlns:ns1="urn:NextMessage"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<return xsi:type="xsd:string">Call mom!</return>
</ns1:getMessage>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
21
SOAP Endpoint Reference
POST /servlet/rpcrouter HTTP/1.1
Host: www.messages.com
Content-Type: text/xml; charset="utf-8"
Content-Length: nnnn
SOAPAction: ""
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
<SOAP-ENV:Body>
<ns1:getMessage xmlns:ns1="urn:NextMessage"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<UserID xsi:type="xsd:string">JDoe</UserID>
<Password xsi:type="xsd:string">0JDOE0</Password>
</ns1:getMessage>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
85.34.235.95 80/servlet/rpcrouter/getMessage
22
SOAP client-server interaction
23
The Apache eXtensible Interaction System (AXIS)
A very flexible SOAP engine from Apache- Open and pluggable architecture
- Design to cope with various deployment configuration
• From very simplistic to highly sophisticated configurations
The Java Web Services facility (JWS)- Drop-in development
• Simplest and quickest way to deploy a Java-base Web Service
• Rename source file from xxx.java to xxx.jws
• Drop xxx.jws into JWS directory
24
APIs de Java
SAAJ (SOAP with Attachment API for Java)tratar mensajes SOAP como objetos Java
JAX-RPC (Java API for XML based RPC)WSDL/XML <-> Java
API para cliente: WSDL, Invocación, proxy dinámico
JWSDLacceso a descripciones WSDL
JAXR (Java API for XML registries)acceso a registros de servicios Web
...
25
Creación de un Servicio Web
Utilizar JWS- Con limitaciones (no package, ...)
WSDD (Web Service Deployment Descriptor)
26
Creación de un cliente
1. Acceder a WSDLhttp: ....Calculator.jws?wsdl -> almacenar Calculator.wsdl
2. Generar stubsjava org.apache.axis.wsdl.WSDL2Java –p Calculator Calculator.wsdl
3. Clases generadas ls Calculator/ *.java
4. Compilar javac Calculator/ *.java
5. Compilar cliente javac ClienteCalculator.java
6. Ejecutar cliente java ClienteCalculator
27
What is WSDL?
• WSDL describes network services by using an XML grammar.
• A WSDL document has a role similar to an IDL file in CORBA or the Remote Interface in a Java RMI implementation.
SOAP specifies the communication between a
requester and a provider
WSDL describes the services offered by the provider (an “endpoint”)
and might be used as a recipe to generate the proper SOAP messages to access the services.
28
Complete picture of distributed applications
(using WS)
29
WSDLservice
port
binding
port types
message
operation
types
1-M
1-1
1-1
1-M
1-M
1-M
30
Types: xSchema definition of data
Port Types
Service
Port
Binding
Operations
Messages
Types
<types><schema
targetNamespace="http://example.com/stockquote.xsd"xmlns="http://www.w3.org/2000/10/XMLSchema"><element name="TradePriceRequest">
<complexType><element name="tickerSymbol" type="string"/>
</complexType></element><element name="TradePrice">
<complexType><element name="price" type="float"/>
</complexType></element>
</schema></types>
31
Messages: meaningful collections of Types
Port Types
Service
Port
Binding
Operations
Messages
Types
<message name="GetLastTradePriceInput"><part name="body" element="xsd1:TradePriceRequest"/>
</message>
<message name="GetLastTradePriceOutput"><part name="body" element="xsd1:TradePrice"/>
</message>
32
Operations: available Methods
Port Types
Service
Port
Binding
Operations
Messages
Types
<operation name="GetLastTradePrice"><soap:operation
soapAction="http://example.com/GetLastTradePrice"/><input>
<soap:body use="literal"/></input><output>
<soap:body use="literal"/></output>
</operation>
33
Port Types: XML in/out for specific methods
Port Types
Service
Port
Binding
Operations
Messages
Types
<portType name="StockQuotePortType"><operation name="GetLastTradePrice">
<input message="tns:GetLastTradePriceInput"/><output message="tns:GetLastTradePriceOutput"/>
</operation></portType>
Maps Operations to Messages
34
Binding: Maps Protocols to Methods (Http, etc.)
Port Types
Service
Port
Binding
Operations
Messages
Types
<binding name="StockQuoteSoapBinding“type="tns:StockQuotePortType"><soap:binding style="document“
transport="http://schemas.xmlsoap.org/soap/http"/><operation name="GetLastTradePrice">
<soap:operation soapAction="http://example.com/GetLastTradePrice"/><input>
<soap:body use="literal"/></input><output>
<soap:body use="literal"/></output>
</operation></binding>
35
Port: Maps URLs to Methods
Port Types
Service
Port
Binding
Operations
Messages
Types
<port name="StockQuotePort" binding="tns:StockQuoteBinding"><soap:address location="http://example.com/stockquote"/>
</port>
36
Service: Packages ports & bindings
Port Types
Service
Port
Binding
Operations
Messages
Types
<service name="StockQuoteService"><documentation>My first service</documentation><port name="StockQuotePort"
binding="tns:StockQuoteBinding"><soap:address
location="http://example.com/stockquote"/></port>
</service>
37
Document structure of WSDL
<definitions> element: the root of any WSDL - The name attribute specifies the name of
the Web Service (usually it corresponds to the file name).
- it contains a set of namespace definitions that are used throughout the document.
- ...
<definitions name ='weatherservice‘
xmlns='http://schemas.xmlsoap.org/wsdl/'>……
</definitions>
38
Document structure of WSDL
<definitions> contains other elements- elements
• types• messages• portType• bindings• services• ...
- Each element within the document may contain a <documentation> element to provide some human readable explanation of the element that is specified.
- In addition, all the elements contain an attribute “name” serving as an identifier.
39
Document structure of WSDL <types> element
- Provide data types definitions- All data type definitions relevant for sending
and receiving the messages described - The specification suggests using XML
schema definitions.
<types><schema
targetNamespace="http://add.fib.upc.es/symbol.xsd"xmlns="http://www.w3.org/2000/10/XMLSchema">
<element name="exampleType">...</element>...
</schema></types>
40
Document structure of WSDL
<message> element- specifiy the data that will be communicated
between a requester and a service- may appear multiple times and consists of a
name and one or more <part> elements. - The parts specify the contents of the
message.<message name='Weather.GetTemperature'><part name='zipcode' type='xsd:string'/><part name='celsius' type='xsd:boolean'/>
</message> <message name='Weather.GetTemperatureResponse'> <part name='Result' type='xsd:float'/> </message>
41
Document structure of WSDL
<operation> element- In order to tie the defined messages
together as a request-response pair corresponding to a method call.
- An operation specifies which message is the input and which message is the output.
<operation name='GetTemperature'>
<input message='wsdlns:Weather.GetTemperature' />
<output message='wsdlns:Weather.GetTemperatureResponse' />
</operation>
42
Document structure of WSDL
<portType> element- The collection of all operations (i.e.
methods) exposed by your service
<portType name='WeatherSoapPort'> <operation name='GetTemperature'> <input message='wsdlns:Weather.GetTemperature' /> <output
message='wsdlns:Weather.GetTemperatureResponse' /> </operation>
<!-- other operations would go here --> </portType>
43
Document structure of WSDL
<binding> element- to bind the operation to the SOAP protocol.
The elements presented so far described our operation in a generic way (Nothing has been said about a concrete implementation).
- Next to a name attribute it contains a type attribute that references a portType and provides predefined binding for protocols such as SOAP, HTTP, and MIME.
<binding name='WeatherSoapBinding' type='wsdlns:WeatherSoapPort' >
…. </binding>
44
Document structure of WSDL
<binding> element (cont)- Binding to SOAP
Inside the <binding> element you have a WSDL SOAP extension element called <soap:binding> which is used to specify the transport protocol you’re using (SOAP can be used over HTTP, SMTP, or possibly any other transport) and the style of request (rpc and document are the two styles).
<soap:binding style='rpc'
transport='http://schemas.xmlsoap.org/soap/http' />
45
Document structure of WSDL <binding> element (cont)
• Then for each operation that this service exposes, you specify the value of the SOAPAction that is used for the HTTP header of SOAP message
<binding name='WeatherSoapBinding' type='wsdlns:WeatherSoapPort' > <soap:binding style='rpc' transport='http://schemas.xmlsoap.org/soap/http' /> <operation name='GetTemperature' > <soap:operation soapAction='http://tempuri.org/action/Weather.GetTemperature'
/>....
</operation> </binding>
46
Document structure of WSDL <binding> element (cont)
• There has to be at least one binding for every portType.
• In order to specify how the input and output messages of this operation are encoded, there is an operation element having three subelements: input, output, and fault. Each operation corresponds to an operation in the portType element.
<binding name='WeatherSoapBinding' type='wsdlns:WeatherSoapPort' > <soap:binding style='rpc' transport='http://schemas.xmlsoap.org/soap/http' /> <operation name='GetTemperature' > <soap:operation soapAction='http://tempuri.org/action/Weather.GetTemperature' /> <input> <soap:body use='encoded' namespace='http://tempuri.org/message/'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/> </input> <output> <soap:body use='encoded' namespace='http://tempuri.org/message/'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/> </output> </operation> </binding>
47
Document structure of WSDL
<service> and <port> element- A service is a set of related ports.
- The binding is specified within the port element.
- In order to bind to the SOAP protocol a <soap:address> is defined.
• It contains a name and a location that defines an address of the same type as the transport specified in the soap:binding element. That means that we have to define a HTTP address.
See the Web Service Example
48
WSDL Structure Overview
portType- Abstract definition of
a service (set of operations)
Multiple bindings per portType:- How to access it
Ports- Where to access it
Service
Port(e.g. http://host/svc)
Binding(e.g. SOAP)
Abstract interface
portType
operation(s)
inMesage outMessage
Port
Binding
49
WSDL Example:
float Weather::GetTemperature(String zipCode, bool celsius)
{
if (celsius)
return 21.7;
else
return 71.06;
}
50
WSDL Example: Defining Services
You can think of the class as the Web service and the GetTemperature method as an operation on that service. To describe this service, you use the WSDL <service> element.
<definitions name ='weatherservice‘
xmlns='http://schemas.xmlsoap.org/wsdl/'> <service name='WeatherService' >
……</service>
</definitions>
51
WSDL Example: Defining Services (cont.)
Each service is defined using a service element. Inside the service element, you specify the different ports on which this service is accessible.
The port definition would be like this:
<port name='WeatherSoapPort' binding='wsdlns:WeatherSoapBinding' >
<soap:address
location='http://localhost/demos/wsdl/devxpert/weatherservice.asp' />
</port>
52
WSDL Example: Defining Services (cont.)
A Web service does not have to be exposed using SOAP. For example, if your Web service is exposed via HTTP GET, the port element would contain an <http:address/> element similar to this:
<http:address location="http://localhost/demos/wsdl/devxpert/weatherGET.asp"/>
A Web service may be accessible on many ports. For example, you might make your service available via SOAP and HTTP GET and possibly even via SMTP. For this Web service, you would have three ports each one with a different name.
53
WSDL Example: What’s Your Message? (cont.)
To use Web services in a remote procedure call (RPC) model, there are two messages you must describe.
To describe the message structures, you use the WSDL <message> element. Each <message> contains zero or more <part> elements. A <part> corresponds to a parameter or a return value in the RPC call.
<message name='Weather.GetTemperature'><part name='zipcode' type='xsd:string'/><part name='celsius' type='xsd:boolean'/>
</message> <message name='Weather.GetTemperatureResponse'> <part name='Result' type='xsd:float'/> </message>
54
WSDL Example: Port Types and Operations
An operation specifies which message is the input and which message is the output like this:
<operation name='GetTemperature'>
<input message='wsdlns:Weather.GetTemperature' />
<output message='wsdlns:Weather.GetTemperatureResponse' />
</operation>
55
WSDL Example: Port Types and Operations (cont.)
The collection of all operations (i.e. methods) exposed by your service is called a portType and is defined using the WSDL <portType> element like this:
<portType name='WeatherSoapPort'> <operation name='GetTemperature'> <input message='wsdlns:Weather.GetTemperature' /> <output
message='wsdlns:Weather.GetTemperatureResponse' /> </operation>
<!-- other operations would go here --> </portType>
56
WSDL Example: Binding It All Together
We are now making a transition from abstract data types, messages, and operations to concrete physical representation of messages on the wire. To define the concrete aspects of operations, you use the WSDL <binding> element:
<binding name='WeatherSoapBinding' type='wsdlns:WeatherSoapPort' >
…. </binding>
57
WSDL Example: Binding It All Together (cont.)
Inside the <binding> element you have a WSDL SOAP extension element called <soap:binding> which is used to specify the transport protocol you’re using (SOAP can be used over HTTP, SMTP, or possibly any other transport) and the style of request (rpc and document are the two styles). For example:
<soap:binding style='rpc' transport='http://schemas.xmlsoap.org/soap/
http' />
58
WSDL Example: Binding It All Together (cont.)
Then for each operation that this service exposes, we specify the value of the SOAPAction HTTP header :
<binding name='WeatherSoapBinding' type='wsdlns:WeatherSoapPort' > <soap:binding style='rpc'
transport='http://schemas.xmlsoap.org/soap/http' /> <operation name='GetTemperature' > <soap:operation
soapAction='http://tempuri.org/action/Weather.GetTemperature' />....
</operation> </binding>
59
SOAP client-server interaction
(rep)
60
WSDL Example: Binding It All Together (cont.)
Finally, we must specify how the input and output messages of this operation are encoded, the complete binding looks like this:
<binding name='WeatherSoapBinding' type='wsdlns:WeatherSoapPort' > <soap:binding style='rpc' transport='http://schemas.xmlsoap.org/soap/http' /> <operation name='GetTemperature' > <soap:operation soapAction='http://tempuri.org/action/Weather.GetTemperature' /> <input> <soap:body use='encoded'
namespace='http://tempuri.org/message/' encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
</input> <output> <soap:body use='encoded'
namespace='http://tempuri.org/message/' encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
</output> </operation> </binding>
61
What is UDDI?
Universal Description, Discovery, and Integration (UDDI) is a standard designed to provide a searchable directory of businesses and their Web Services.
Thus, it represents the service broker that enables service requesters to find a suitable service provider.
62
Complete picture of distributed applications
(using WS)
63
What is UDDI?
To get access to the UDDI services, the UDDI directory exposes a set of APIs in the form of a SOAP-based Web Service.
UDDI APIs - Publication API - Authenticated set of
operations that allow organizations to publish businesses, services, service type specifications
- Inquiry API - Non authenticated public set of operations that allows users to extract information out of the UDDI registry.
64
What is UDDI?
UDDI classifies businesses and services according to standard taxonomies
Why Classification ?- Searches based on keywords alone, could return a
large set of hits for a particular search- Classification of services and businesses allows to
perform better searches
Registry Data• White Pages• Yellow Pages• Green Pages• ServiceType Registrations
65
What is UDDI?(In many ways UDDI is designed like a phone book)
White Pages- contains business name, text description, contact info and other
related info.
- contains classification information about the business entity and
types of the services the entity offers. Searches can be performed to locate businesses which service a particular industry or product category, or that are located within a specific geographic region.
Green Pages- contains information about how to invoke the offered services.
• If a business entity were to offer its catalog online, its Green pages entry would have a reference to its catalog URL
Yellow Pages
Green Pages
White Pages
66
Web Service Deployment
Remote UDDIWeb Service
Registry
Deploy ApplicationAs Service
ServiceProvider
WSDL FileGeneration and
Registration
WriteApplication
StartListener
WSDL
SOAP Request
1
67
Dynamic Service Invocation
Remote UDDIWeb Service(Registry)
AutomaticService
Selection
Service Requestor
DynamicClient Code Generation
AutomatedWeb Service
Lookup
Web ServiceInvocation
SOAP Request
(SOAP Response)
SOAP Request
SOAP Response
1
Remote Web service
Publish Web Service
2
3
4
5
WSDL(s)
68
Business registry nodes- http://uddi.microsoft.com- http://uddi.ibm.com- http://uddi.<companyname>.com- ...
69
Web Services Performance
New technologies are often marketed with grand promises to solve business problems, but ... PERFORMANCE?
Performance criteria- simultaneous requests, - latency in responding to requests,- levels of operational degradation due to increases
in transaction loads.- ...
70
Web Services Performance
Web service component stack
71
Web Services Performance
Impact of parsing and marshalling
(source: http://www-106.ibm.com/developerworks/library/ws-best9)
Recommended