Download presentation
Presentation is loading. Please wait.
1
Web Services
2
Outline What are web services? WS Protocol Stack SOAP WSDL UDDI
Definitions Advantages Challenges Architecture WS Protocol Stack SOAP WSDL UDDI
3
Web evolution XML HTML TCP/IP Technology Applications Connect the Web
Text Hypertext Applications FTP, , Gopher Applications Web pages Connect the Web Web services Browse the Web Program the Web
4
Definitions Definition 1: Definition 2: Definition 3:
A web service is a service (“program”) that can be invoked from another program via the web. Definition 2: “Web Services are self-contained, self-describing, modular applications that can be published, located, and invoked across the Web”. Definition 3: A Web Service is a service on the Internet that Use a standardized XML messaging system Not tied to any operating system or programming language
5
Examples Flight Reservation Weather Service Amazon.com web services
Retrieve geographic information Search the web, check spellings One of the first useful Web Services built around SOAP Allows you to integrate your application with Google’s search, spell check, and cached page databases.
6
A Basic Web Service XML XML Language: Java Operating System:
Linux Language: Perl Operating System: Windows 2000
7
Web Services Advantages
Use open, text-based standards, which enable components written in different languages and for different platforms to communicate. Promote a modular approach to programming, so multiple organizations can communicate with the same Web service. Self-describing (metadata for access and use) Discoverable (search and locate in registries) loosely coupled (i.e. Services should not be dependent on each other).
8
Service Oriented Architecture (Basic Model)
WSDL Service Provider Publish Bind SOAP SOAP Service Broker Service User Find SOAP UDDI UDDI – Universal, Description, Discovery, and Integration WSDL – Web Services Description Language SOAP – Simple Object Access Protocol / SOA Protocol
9
Web Service Protocol Stack
Searching / Publishing Web Services Discovery UDDI Description WSDL Describing Web Services interface XML Messaging XML-RPC, SOAP,XML Transport HTTP,SMTP,FTP Encoding messages in XML format Transporting XML messages between client and server
10
Simple Object Access Protocol (SOAP)
SOAP is an XML-based protocol designed to exchange information in a distributed environment (a communication protocol). SOAP is platform & language independent SOAP is a W3C standard
11
SOAP: Message Structure
<?xml version="1.0"?> <soap:Envelope xmlns:soap=" soap:encodingStyle=" <soap:Header> ... </soap:Header> <soap:Body> </soap:Body> </soap:Envelope> SOAP Envelope SOAP Header Headers SOAP Body Message Name & Data
12
SOAP: Request Example
13
SOAP: Response Example
14
SOAP Advantages/Disadvantages
Human-readable XML Easy to debug SOAP runs over HTTP Firewalls not affected Services can be written in any language, platform or operating system. Disadvantages S-L-O W XML produces a lot of overhead for small messages
15
WSDL Web Services Description Language
WSDL is an XML-based format designed to describe the interfaces exposed by a service What a service does? How clients can use it? It can be used with all protocols (HTTP, SMTP, etc.), but it normally runs over HTTP. If sender & receiver share and understand same WSDL file, interoperability is guaranteed.
16
WSDL: Definitions A WSDL document defines services as a collection of network endpoints or ports, where the port types are abstract collection of operations, and the concrete protocol and data format specifications for a particular port type constitutes a reusable binding. Types: a container for data type definitions using some type system such as XSD. Message: an abstract, typed definition of the data being communicated. Operation: an abstract description of an action supported by the service. Port Type: an abstract set of operations supported by one or more endpoints. They are equivalent to interfaces. Binding: a concrete protocol and data format specification for a particular port type. The interfaces are bound to specific network and transport protocols. It is akin to implementing an interface. Port: a single endpoint defined as a combination of a binding and a network address. Service: a collection of related endpoints.
20
WSDL Structure <?xml version="1.0" encoding="UTF-8"?> <definitions> <types> <!– define the types here using XML Schema </types> <message> <!– XML messages the web service uses are defined here </message> <portType> <!– define the input and output parameters here - </portType> <binding> <!– define the network protocol here </binding> <service> <!– location of the service </service> </definitions>
21
The <types> The types element contains XML Schemas defining the datatypes that are to be passed to and from the web service <types> <schema targetNamespace=" xmlns=" <element name="TradePriceRequest"> <complexType> <all><element name="tickerSymbol" type="string"/></all> </complexType> </element> <element name="TradePrice"> <complexType> <all><element name="price" type="float"/></all> </complexType> </element> </schema> </types>
22
The <message> The <message> element is used to define the messages that will be exchanged between the client and the service These message elements contain <part> elements, which will be using types defined in the types element All the parts are namespace qualified <message name="GetLastTradePriceInput"> <part name="body" element="xsd1:TradePriceRequest"/> </message> <message name="GetLastTradePriceOutput"> <part name="body" element="xsd1:TradePrice"/> </message>
23
The <portType> The types and messages have been defined, but they have not been defined in terms of where they fit in the functionality of the web service This is done within <portType> and <operation> elements A portType is analogous to a class An operation is analogous to a method in that class <portType name="StockQuotePortType"> <operation name="GetLastTradePrice"> <input message="tns:GetLastTradePriceInput"/> <output message="tns:GetLastTradePriceOutput"/> </operation> </portType> Therefore, methods can be grouped together in portType elements. Similar to methods in a Java class would be.
24
Types of <operation>
There are four distinct types of operation Synchronous Request-response - The service receives a message and sends a reply Solicit-response - The service sends a message and receives a reply message Asynchronous One-way - The service receives a message Notification - The service sends a message All of these can be defined in WSDL The grammar for a one-way operation is: <wsdl:definitions .... > <wsdl:portType .... > * <wsdl:operation name="nmtoken"> <wsdl:input name="nmtoken"? message="qname"/> </wsdl:operation> </wsdl:portType > </wsdl:definitions> The grammar for a request-response operation is: <wsdl:definitions .... > <wsdl:portType .... > * <wsdl:operation name="nmtoken" parameterOrder="nmtokens"> <wsdl:input name="nmtoken"? message="qname"/> <wsdl:output name="nmtoken"? message="qname"/> <wsdl:fault name="nmtoken" message="qname"/>* </wsdl:operation> </wsdl:portType > </wsdl:definitions> The grammar for a solicit-response operation is: <wsdl:definitions .... > <wsdl:portType .... > * <wsdl:operation name="nmtoken" parameterOrder="nmtokens"> <wsdl:output name="nmtoken"? message="qname"/> <wsdl:input name="nmtoken"? message="qname"/> <wsdl:fault name="nmtoken" message="qname"/>* </wsdl:operation> </wsdl:portType > </wsdl:definitions> The grammar for a notification operation is: <wsdl:definitions .... > <wsdl:portType .... > * <wsdl:operation name="nmtoken"> <wsdl:output name="nmtoken"? message="qname"/> </wsdl:operation> </wsdl:portType > </wsdl:definitions>
25
Defining the type of operation
Presence and order of input/output elements defines the type of operation. Request-response <input><output> Solicit-response <output><input> One-way <input> only Notification <output> only
26
The <binding> element
This element is used to define the mechanism that the client will actually use to interact with the web service The most common choice is currently SOAP The binding element defines the protocol specific information for the portTypes previously defined
27
The binding tag <binding name=“ez3950SOAPBinding” type=“tns:ez3950PortTypes”> The <binding> tag indicates that we will map a <Port Type> to a protocol <soap:binding style=“rpc” transport=“ Indicates we will be using the SOAP binding extensions to map the operations. The alternative to “rpc” is “document”. ( to use GET/POST use < to use MIME use <mime:binding…..> )
28
<service> The final component of a WSDL file is the <service> element The <service> element defines <port> elements that specify where requests should be sent The <soap:address> subelement identifies the URL of the service The precise content of <port> elements will be dependent upon the mechanism, i.e. SOAP, HTTP or MIME <service name="StockQuoteService"> <port name="StockQuotePort" binding="tns:StockQuoteBinding"> <soap:address location=" </port> </service>
29
WSDL: Example (1/5) <?xml version="1.0"?>
<definitions name="StockQuote" targetNamespace=" xmlns:tns=" xmlns:xsd=" xmlns:xsda=" xmlns:soap=" xmlns:soapenc=" xmlns=" <types> <schema targetNamespace=" xmlns=" <complexType name="TimePeriod"> <all> <element name="startTime" type="xsd:timeInstant"/> <element name="endTime" type="xsd:timeInstant"/> </all> </complexType>
30
WSDL: Example (2/5 <complexType name="ArrayOfFloat">
<complexContent> <restriction base="soapenc:Array"> <attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:float[]"/> </restriction> </complexContent> </complexType> </schema> </types> <message name="GetTradePricesInput"> <part name="tickerSymbol" element="xsd:string"/> <part name="timePeriod" element="xsda:TimePeriod"/> </message>
31
WSDL: Example (3/5) <message name="GetTradePricesOutput">
<part name="result" type="xsda:ArrayOfFloat"/> <part name="frequency" type="xsd:float"/> </message> <portType name="StockQuotePortType"> <operation name="GetLastTradePrice" parameterOrder="tickerSymbol timePeriod result frequency"> <input message="tns:GetTradePricesInput"/> <output message="tns:GetTradePricesOutput"/> </operation> </portType>
32
WSDL: Example (4/5) <binding name="StockQuoteSoapBinding" type="tns:StockQuotePortType"> <soap:binding style="rpc" transport=" <operation name="GetTradePrices"> <soap:operation soapAction=" <input> <soap:body use="encoded" namespace=" encodingStyle=" </input> <output> <soap:body use="encoded" namespace=" encodingStyle=" </output> </operation> </binding>
33
WSDL: Example (5/5) <service name="StockQuoteService">
<documentation>My first service</documentation> <port name="StockQuotePort" binding="tns:StockQuoteBinding"> <soap:address location=" </port> </service> </definitions>
34
UDDI Universal Description, Discovery and Integration
A Web Service registry & discovery mechanism for retrieving pointers for web services interfaces Publish your business information and technical details of your Web Service Search for other Web Services and connect to them UDDI is not only limited to XML Web Services The key to the ultimate success of Web services, but has some key limitations, and alternative discovery methods are provided by ebXML and WS-Inspection.
35
UDDI Details SOAP is used to talk to UDDI registries White pages
Business information (name, contact info) Yellow pages Categorization (industry, products, location) Green pages Technical specifications (service description)
36
Publishing Web Services with .NET (1/2)
Visual Studio .NET 2003 From the File menu, point to New, and click New Project Select ASP.NET Web service Change the Location if necessary Click OK Open the code window Add the following code
37
Publishing Web Services with .NET (2/2)
[WebMethod] public double toLire(double euro) { return euro * ; } public double toEuro(double lire) return lire / ;
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.