web services distributed computing 9 sep,2008 shahid mahmood
TRANSCRIPT
Web ServicesWeb Services
Distributed Computing9 Sep,2008
Shahid Mahmood
ServiceServiceA service is a function that is
well-defined, self-contained, and does not depend on the context or state of other services
What’s Web Service?What’s Web Service?“Software application identified by a URI, whose
interfaces and bindings are capable of being defined, described, and discovered as XML artifacts” – W3C Web Services Architecture Requirements, Oct. 2002
“Programmable application logic accessible using Standard Internet Protocols…” – Microsoft
“An interface that describes a collection of operations that are network accessible through standardized XML messaging …” – IBM
“Software components that can be spontaneously discovered, combined, and recombined to provide a solution to the user’s problem/request … “ - SUN
Web Services: The Next Web Services: The Next Horizon for e-businessHorizon for e-businessAllow companies to reduce the cost
of doing e-business, to deploy solutions faster◦Need a common program-to-
program communications modelAllow heterogeneous applications to
be integrated more rapidly, easily and less expensively
Facilitate deploying and providing access to business functions over the Web
Web Service InterfaceWeb Service InterfaceA web service interface generally
consists of a collection of operations that can be used by the client over the internet.
A web service may either be managed by a web server along with the web pages or it may be totally separate service.
Web Servers such as Google, Amazon, Yahoo, eBay provides web service interfaces to manipulate their resources
Web services communication Web services communication patternpatternWeb services can process XML-
formatted SOAP messages.An alternative is the
REST(representational state transfer) approach.
Web services communication can be ◦Synchronous/Asynchronous◦Event Based
Combination of web Combination of web servicesservices
hotel booking
Travel Agent
flight booking
hire car bookingServiceClient
flight booking
hotel booking
hire car booking
The ‘travel agent service’ combines other web services
Underlying TechnologiesUnderlying Technologies XML Is the GlueXML Is the Glue
Program the Web
XML
Browse the Web
HTML
TCP/IP
Connect the Web
Technology
Innovation
Connectivity PresentationConnecting ApplicationsFTP, E-mail, Gopher
Web Pages Web Services
What is XML?What is XML?
XML is a “use everywhere” data specification
9
DocumentsConfiguration
Database
Application X
Repository
XML XML
XML XML
Web services infrastructure Web services infrastructure and componentsand components
Security
Service descriptions (in WSDL)
Applications
Directory service
Web Services
XML
Choreography
SOAP
URIs (URLs or URNs) HTTP, SMTP or other transport
Web Service StackWeb Service Stack
SOAP: Simple Object Access SOAP: Simple Object Access ProtocolProtocol
What is SOAP?◦ SOAP is a communication protocol ◦ SOAP is for communication between
applications ◦ SOAP is a format for sending messages ◦ SOAP is designed to communicate via Internet ◦ SOAP is platform independent ◦ SOAP is language independent ◦ SOAP is based on XML ◦ SOAP is simple and extensible ◦ SOAP will be developed as a W3C standard
SOAP: Simple Object Access SOAP: Simple Object Access ProtocolProtocol SOAP 1.0: Microsoft, Userland,
DevelopMentor Specific to COM and HTTP
SOAP 1.1: includes contributions from IBM and Lotus Substitutable transport binding (not just HTTP) Substitutable language binding (e.g. Java) Substitutable data encoding Completely vendor-neutral Independent of: programming language, object
model, operating system, or platform SOAP 1.2: current working draft from w3.org
“XML Protocol” working group
SOAP Message StructureSOAP Message Structure Request and Response messages
Request invokes a method on a
remote object Response returns result of running
the method SOAP specification defines an “envelop”
“envelop” wraps the message itself Message is a different vocabulary Namespace prefix is used to distinguish the two
parts
Application-specific message vocabulary
SOAP Envelop vocabulary
SOAP message in an SOAP message in an envelopeenvelope
envelope
header
body
header element
body element
header element
body element
SOAP SOAP Example of a simple request Example of a simple request without headerswithout headers
m:exchange
env:envelope xmlns:env =namespace URI for SOAP envelopes
m:arg1
env:body
xmlns:m = namespace URI of the service description
Hellom:arg2
World
In this figure and the next, each XML element is represented by a shaded box with its name in italic followed by any attributes and its content
Example of a reply to the Example of a reply to the request request
env:envelope
xmlns:env = namespace URI for SOAP envelope
m:res1
env:body
xmlns:m = namespace URI for the service description
m:res2World
m:exchangeResponse
Hello
HTTP POST Request in SOAP HTTP POST Request in SOAP client-server communicationclient-server communication
endpoint address
action
POST /examples/stringerHost: www.cdk4.netContent-Type: application/soap+xml
Action: http://www.cdk4.net/examples/stringer#exchange
<env:envelope xmlns:env= namespace URI for SOAP envelope ><env:header> </env:header><env:body> </env:body></env:Envelope>
So
ap
me
ssa
ge
HT
TP
hea
de
r
SOAP Request MessageSOAP Request Message
<?xml version="1.0"?><soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope" soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
<soap:Body xmlns:m="http://www.stock.org/stock">
</soap:Body>
</soap:Envelope>
<m:GetStockPrice> <m:StockName>IBM</m:StockName> </m:GetStockPrice>
SOAP Envelope
Message
SOAP EnvelopeNamespace
MessageNamespace
SOAP Response MessageSOAP Response Message
<?xml version="1.0"?><soap:Envelopexmlns:soap="http://www.w3.org/2001/12/soap-envelope"soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding"> <soap:Body xmlns:m="http://www.stock.org/stock">
</soap:Body></soap:Envelope>
<m:GetStockPriceResponse> <m:Price>34.5</m:Price></m:GetStockPriceResponse>
SOAP Envelope
Message
Result returned in
Body
Why SOAP?Why SOAP?Other distributed technologies failed on the
Internet◦ Unix RPC – requires binary-compatible Unix
implementations at each endpoint◦ CORBA – requires compatible ORBs◦ RMI – requires Java at each endpoint◦ DCOM – requires Windows at each endpoint
SOAP is the platform-neutral choice◦ Simply an XML wire format◦ Places no restrictions on the endpoint
implementation technology choices
SOAP Usage ModelsSOAP Usage ModelsRPC-like message exchange
◦ Request message bundles up method name and parameters
◦ Response message contains method return values
◦ However, it isn’t required by SOAPSOAP specification allows any kind of body
content◦ Can be XML documents of any type◦ Example:
Send a purchase order document to the inbox of B2B partner
Expect to receive shipping and exceptions report as response
Web Services Description Web Services Description LanguageLanguage
What is WSDL? WSDL is an XML document WSDL is used to describe Web services WSDL is also used to locate Web services WSDL is a W3C standard
Operational informationOperational information about the service Location of the service Service interface Implementation details for the service
interface
Web Services Description Web Services Description Language Language (WSDL)(WSDL)
is a format for describing a Web Services interface. It is a way to describe services and how they should be bound to specific network addresses. WSDL has three parts:◦Definitions ◦Operations ◦Service bindings
WSDL 2.0 Interface definition WSDL 2.0 Interface definition for Stock Quote Servicefor Stock Quote Service<?xml version="1.0"?> <definitions name="StockQuote“
targetNamespace="http://example.com/stockquote/definitions" xmlns:tns="http://example.com/stockquote/definitions" xmlns:xsd1="http://example.com/stockquote/schemas" xmlns:soap="http://www.w3.org/2003/11/wsdl/soap12" xmlns="http://www.w3.org/2003/11/wsdl"> <import namespace="http://example.com/stockquote/schemas" location="http://example.com/stockquote/stockquoteV20.xsd"/> <types> <schema targetNamespace="http://example.com/stockquote/definitions"> <element name="GetLastTradePriceInput" type="xsd1:TradePriceRequest"/> <element name="GetLastTradePriceOutput" type="xsd1:TradePrice"/> </schema> </types> <interface name="StockQuoteInterface"> <operation name="GetLastTradePrice" pattern="http://www.w3.org/2003/11/wsdl/in-out"> <input message="tns:GetLastTradePriceInput"/> <output message="tns:GetLastTradePriceOutput"/> </operation> </interface>
</definitions>
WSDL 2.0 Implementation definition for WSDL 2.0 Implementation definition for Stock Quote ServiceStock Quote Service<definitions name="StockQuote“
targetNamespace="http://example.com/stockquote/service" xmlns:tns="http://example.com/stockquote/service" xmlns:wsoap="http://www.w3.org/2003/11/wsdl/soap12" xmlns:defs="http://example.com/stockquote/definitions" xmlns="http://www.w3.org/2003/11/wsdl">
<import namespace="http://example.com/stockquote/definitions" location="http://example.com/stockquote/stockquoteV12.wsdl"/>
<binding name="StockQuoteSoapBinding" interface="defs:StockQuoteInterface"> <wsoap:binding protocol="http://www.w3.org/2003/11/wsdl/http"/>
<operation name="GetLastTradePrice">
<wsoap:operation soapAction="http://example.com/GetLastTradePrice"/>
<input> <wsoap:body/> </input>
<output> <wsoap:body/> </output>
</operation> </binding>
<service name="StockQuoteService">
<documentation>My stock quote service</documentation>
<endpoint name="StockQuoteEndPoint" binding="tns:StockQuoteSoapBinding"> <wsoap:address location="http://example.com/stockquote"/> </endpoint>
</service> </definitions>
WSDL – DEFINITIONWSDL – DEFINITIONAre generally expressed in XML, include both
data type definitions and message definitions that use the data type definitions.
These definitions are usually based upon some agreed upon XML vocabulary agreement. ◦ within an organization or between
organizations. ◦ industry-wide vocabulary.
If data type and message definitions need to be used between organizations, then most likely an industry-wide vocabulary will be used
BussinessXML, AccoutingXML, PhysicsXML, LegalXML, MathXML
http://www.service-architecture.com/xml/articles/xml_vocabularies.html
WSDL - OPERATIONWSDL - OPERATIONOperations describe actions for the
messages supported by a Web service. There are four types of operations:
One-way: One-way: Messages sent without a reply required
Request/response: Request/response: The sender sends a message and the received a reply.
Solicit response: Solicit response: A request for a response. (The specific definition for this action is pending.)
Notification: Notification: Messages sent to multiple receivers. (The specific definition for this action is pending.)
WSDL – SERIVCE BINDINGWSDL – SERIVCE BINDINGService bindings connect port types
to a port. A port is defined by associating a
network address with a port type. A collection of ports defines a service. This binding is commonly created
using SOAP, but other forms may be used. ◦These other forms could include
CORBA Internet Inter-ORB Protocol (IIOP), DCOM, .NET, Java Message Service (JMS), o WebSphere MQ to name a few.
Basic Parts of WSDLBasic Parts of WSDL
WSDL 2.0 Conceptual WSDL 2.0 Conceptual ModelModel
WSDL 2.0 SkeletonWSDL 2.0 Skeleton<definitions targetNamespace="xs:anyURI"> <documentation /> ? [<import /> | <include /> ] * <types /> ? [<interface /> | <binding /> | <service /> ] * </definitions>
WSDL 2.0 Skeleton - WSDL 2.0 Skeleton - DefinitionsDefinitionsDefinitions◦root element of any WSDL document. ◦serves as a container which holds all
the necessary information about the service and its attributes.
◦targetNamespace attribute of the definitions element is a required attribute of type anyURI. The namespace can directly or indirectly
define the semantics of the WSDL. Also, the definitions element can have other
optional attributes which correspond to various namespaces that may be used with in the WSDL document.
WSDL 2.0 Skeleton – Include WSDL 2.0 Skeleton – Include & Import& Import
Include element helps to modularize the web service descriptions. The location attribute is mandatory and specifies the
location of these WSDL documents. The actual value of the target namespace of the included
WSDL must match the target namespace of the definitions element in the including WSDL
Import The concept behind the import element is very similar to that of
include element, except that the imported WSDL can be in different target namespaces.
The namespace attribute for the import element is mandatory while the location attribute is optional.
WSDL 2.0 Skeleton – WSDL 2.0 Skeleton – TypesTypes Typeselement defines the data types used by
the exchanged messages. WSDL uses W3C XML Schema as its
preferred schema language. Schemas may be used by importing or
embedding within the types element of the WSDL document. Importing can be done using the construct
xs:import while embedding uses the construct xs:schema.
WSDL 2.0 Skeleton – WSDL 2.0 Skeleton – InterfaceInterface Interface element encloses a named set of abstract
operations and the abstract messages. can optionally extend one or more other
interfaces. interface operation element has name and
pattern as required attributes, while style is an optional attribute. Features defines functionalities associated with
the message exchanges between communicating parties, which might include reliability, security, correlation, and routing.
Property is used to control the behavior of a feature. It has a set of possible and permissible values specified by references to a schema description.
WSDL 2.0 Skeleton – WSDL 2.0 Skeleton – BindingBinding Binding element defines the underlying transport and
wire format for messages. Each binding in the WSDL references to an interface.
All operations defined within the interface must be bound in the binding.
An endpoint in the service component references a binding.
Both endpoints and bindings are modeled to support flexibility and location transparency.
Multiple endpoints with different network address can still share the same protocol binding.
WSDL 2.0 Bindings specification defines binding extensions for protocols and message formats such as SOAP, HTTP and MIME.
WSDL 2.0 Skeleton – WSDL 2.0 Skeleton – ServiceServiceService
◦element describes a set of endpoints which refer to a single network address for a binding.
◦All other protocol specific information is contained in the binding. Service can be referred by QName.
◦service element has a name and interface which are required attributes.
Universal Description, Universal Description, Discovery and Integration Discovery and Integration (UDDI) (UDDI) What is UDDI?
◦ Directory service where businesses can register and search for Web services Directory for storing information about web
services Directory of web service interfaces described
by WSDL ◦ UDDI communicates via SOAP
What is UDDI Based On? ◦ Uses W3C Internet standards such as XML,
HTTP, and DNS protocols◦ UDDI uses WSDL to describe interfaces to web
services
WSDL 2.0 Infoset, Schema WSDL 2.0 Infoset, Schema and Component Modeland Component Model
UDDI Roles and OperationsUDDI Roles and Operations Service Registry
Provides support for publishing and locating services
Like telephone yellow pages Service Provider
Provides e-business services
Publishes these services through a registry
Service requestor Finds required services via
the Service Broker Binds to services via
Service Provider
UDDIUDDIThe VisionThe Vision
Marketplace
Search Portal
Marketplace
Search Portal
Marketplace
Business Users
Advanced Discovery via Portals and Marketplaces
UDDI Registries and Protocol
Technical Users
How can UDDI be Used? How can UDDI be Used?
UDDI Benefits UDDI Benefits Making it possible to discover the right
business from the millions currently online
Defining how to enable commerce once the preferred business is discovered
Reaching new customers and increasing access to current customers
Expanding offerings and extending market reach
Thank UThank U
Lecture has prepared from Sir Atif Kamal slides with some modifications and enhancement