Introduzione ai Web s Claudio Bettini Web Computing Programming with distributed components on the Web: Heterogeneous Distributed Multi-language 1
Web : Definitions Component for Web Programming Self-contained, self-describing, modular component that can be published, located, and invoked across the Web Web s: Properties can be used either internally or exposed externally over the Internet accessible through a standard interface allows heterogeneous systems to work together as a single web of computation 2
Properties Loosely coupled Ubiquitous communication Universal data format -Oriented Architecture Provider Publish Bind Broker Find User 3
Web Scenario Provider builds and defines the service in WSDL Provider registers the service in UDDI User finds the service by searching UDDI registry User application binds to the Web service and invokes its operations via SOAP Web Architecture Interactions: SOAP Data: XML Provider Communication: HTTP Publish UDDI Bind SOAP Broker UDDI/WSDL Find User 4
Web s Protocols Web Consumer Find a http://www.uddi.org Link to discovery document Discovery http://yourservice.com HTML with link to WSDL How do we talk? (WSDL) http://yourservice.com/?wsdl return service descriptions (XML) Let me talk to you (SOAP) http://yourservice.com/svc1 return service response (XML) UDDI Web Infrastructure Elements Directories central location to locate Web s provided by other organizations (e.g. UDDI registry) Discovery locating WSDL for a particular Web Description defines what interactions the Web supports Wire Formats enable universal communication (e.g. SOAP) 5
Web s References Understanding Web s, Eric Newcomer, Addison Wesley, 2002. La Web s Activity del W3C: http:// ://www.w3.org/2002/ws/ Il sito Sun: http://java.sun.com/webservices Il sito Microsoft: http://msdn.microsoft.com/webservices SOAP 6
SOAP XML Protocol Simple, lightweight XML protocol for exchanging structured and typed information on the Web Envelope- what is in a message & how to process Set of Encoding rules to express app data types Convention for representing RPC calls/responses Modular and Extensible No Application or Transport semantics Think Web based datagram <SOAP:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" SOAP:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <SOAP:Body> <m:creditaccount xmlns:m= other-uri > <AccountID>9024334</AccountID> <Amount>123.45</Amount> <m:/creditaccount> </SOAP:Body> </SOAP:Envelope> SOAP: a lightweight approach Basically, SOAP is : A XML serialization format Communication of the format inside HTTP payload When containing SOAP information, the HTTP request/response pair is called a SOAP method Response payload is optional Fault notification either via HTTP faults or SOAP:Fault An XML messaging specification Type mapping based on XML Schema RPC model inspired by CORBA IIOP SOAP 1.2 is a W3C Recommendation (June 2003) 7
SOAP XML and messaging MIME XML Envelope Message Header Message Body HTTP SOAP is a minimal protocol for invoking methods on remote services/components /objects Functionally closer to RPC/IIOP than to DCOM/RMI Two views of a SOAP call yet another RPC protocol Request includes in and in-out parameters Response includes out and in-out parameters a general-purpose messaging protocol Request carries a single serialized request object Response carries a single serialized response object 8
HTTP security issues HTTP is available on all platforms HTTP requires little runtime support and is not bandwidth-hungry hungry Few/no packets exchanged to set up/maintain sessions From our point of view: HTTP - port 80 is typically the only thing usable over firewalls HTTP 1.1 security is simple and effective, but was conceived for document-transfer transfer applications and definitely not for Web services SOAP structure HTTP payload consists of a SOAP:Envelope XML element Consists of optional Header + mandatory Body elements SOAP namespace recommended SOAP:Body element contains a single serialized instance of a named type Must be first child element of SOAP:Body This is the SOAP payload SOAP:Header element is a collection of serialized instances of named types Mandatory/optional extensions 9
Object/class vs. document/schema obj arg2 arg1 arg0 return addr this arg0 arg1 arg2 Classname: method { T arg1; T arg2; T arg3;} obj.method(arg1, arg2, arg3); <SOAP:Envelope> <SOAP:Body> <method xmlns= soapuri > <arg0>value</arg0> <arg1>value</arg1> <arg2>value</arg2> </method> </SOAP:Body> </SOAP:Envelope> <type name= method > <element name= arg1 type= T /> <element name= arg2 type= T /> <element name= arg3 type= T /> </type> SOAP in a nutshell POST /somepath/sample.pl HTTP/1.1 Content-Type: text/xml SOAPActor: interfaceuri#getquote Content-Length: nnnn <SOAP:Envelope xmlns:soap= uri for SOAP namespace > <SOAP:Body> <GetQuote xmlns= interfaceuri > 200 OK <sourcezip>20125</sourcezip> <destzip>26013</destzip> <weight>200</weight> <servicetype>overnight</servicetype> </Mult> </SOAP:Body> </SOAP:Envelope> Content-Type: text/xml Content-Length: nnnn <SOAP:Envelope xmlns:soap= uri for SOAP namespace > <SOAP:Body> <GetQuoteResponse xmlns= interfaceuri <Amount>30</Amount> </GetQuoteResponse> </SOAP:Body> </SOAP:Envelope> 10