290 likes | 389 Views
Web Services a gentle intro. Martin Q. Zhao CSC colloquium November 8, 2013. Outline . Components and Services The Evolution of Distributed Computing The Concept of Web Services WS-related Technologies Create, Publish, and Consume a WS. What is a Service?.
E N D
Web Servicesa gentle intro Martin Q. Zhao CSC colloquium November 8, 2013
Outline Components and Services The Evolution of Distributed Computing The Concept of Web Services WS-related Technologies Create, Publish, and Consume a WS
What is a Service? • Service in everyday context: • work done for somebody else (Bing dictionary) • the work performed by one that serves (Webster) • What are the advantages of a service? • Expertise • Efficiency and cost effectiveness • Reusability (everyone can request the same service) • Loosely coupling (no need to worry about how it’s done)
Service in Software • Service in software context: • task performed by one app (server) for another app (client) • Software component: • Provides a service that confirms to a set of required operations • E.g., DBMS provides CRUD operations
Component-Based Design Web Server Application Server Also known as distributed architecture Break up application logic and distribute cohesive chunks of functions (services) into loosely coupled reusable modules (components) Make building complexsystems easier
Data and Operations • Fundamental tasks of software applications = automating information transformation processes • Organize information: define and store • Perform transformation: manipulating data based on application logic • Applications can share data and operations • Students/professors/deans/registrars share course data • Various E-Business sites use FedEx delivery service (including operations like pricing, tracking, etc.)
Sharing Data: Asynch. vs. Synch. Appl. A Appl. B Appl. A Appl. B write read Shared Memory File Appl. B Appl. A Appl. C Appl. A read Appl. B Appl. D write read read Database
Service-Based Integration • Middleware independent data format [XML] • Refined concept of registry [UDDI] • Refined interface definition [WSDL] • SOAP WebServices Messaging • Separate n/w & marshaling • Scalable connectivity • Guaranteed delivery Object Request Brokers (ORBs) • Language independent interface [IDL] • Initial concept of registry • Separate n/w & marshaling Aka distributed objects Remote Procedure Call (RPC) • Functionality sharing • Interface description • Platform independent Aka Client/Server Sockets • Connectivity • Real-time data sharing • Data sharing only • Limited data type • Tightly coupled
What is a Web Service? [...] a software system designed to support interoperable machine-to-machine interaction over a network. It has an interface described in a machine-processable format (specifically WSDL). Other systems interact with the Web service in a manner prescribed by its description using SOAP messages, typically conveyed using HTTP with an XMLserialization in conjunction with other Web-related standards. A WS is a SW service accessible on the Web. A Web service is a software function provided at a network address over the web or the cloud, and it is "always on" (as in the concept of utility computing) . The W3C defines a "Web service" as:
How Does It Work? • Web services are abound with a number of standards • XML: machine-independent communication language • HTTP-based: supported by all operating systems • WSDL: XML-based interface description language • SOAP(simple object access protocol): specification for exchanging structured information • UDDI(Universal Description, Discovery and Integration ): common means for service lookup
XML • Extensible Markup Language • W3C standard since late 90’s : fundamental to WS • Use tags to markup contents (in Unicode character set) and relationships among them • Use DTD (document type definition) and later XSD (XML Schema Definition) to define schema and validate docs • Advantages for WS • Independent from H/W and S/W platforms • Support any structure yet maintain it in transit
WSDL • Web Services Description Language (since 2001) • Programming language and middleware independent • Free to choose a communication protocol • Free to choose any convenient message format (SOAP, RESTful + XML/JSON, XML RPC, etc) • A wide range of service operations to choose from (synch, asynch, RESTful, SOAP) • A service end point (N/W address) can be specified
Typical Message Formats <?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:Header> </soap:Header> <soap:Body> ... message data ... <soap:Fault> </soap:Fault> </soap:Body> </soap:Envelope> SOAP <profile> <firstName>Jakob</firstName> <lastName>Jenkov</lastName> <address> <street>The Road 123</street> <zip>12345</zip> <city>Copenhagen</city> </address> </profile> { firstName : "Jakob", lastName : "Jenkov", address : { street : "The Road 123", zip : "12345", city : "Copenhagen" } } XML JSON
UDDI • Universal Description, Discovery and Integration • Platform-independent, XML-based registry • Three components • White page: address, name • Yellow page: categories • Green pages: tech info • The process • Service provide publishes WSDL • Service consumer looks up WS • Service consumer consumes WS
WS vs. Distributed Objects • CORBA – common object request broker architecture Service Consumer [ object, uuid(a03d1420-b1ec-11d0-8c3a-00c04fc31d2f), ] interface IFace1 : IUnknown { HRESULT MethodA([in] short Bread, [out] BKFST * pBToast); HRESULT MethodB([in, out] BKFST * pBPoptart); };
Commonly Used Web Services • Get five days weather report for a given zip code (USA) • Get FedEx shipping rate • Get the Barnes & Noble price by ISBN • Get name and address data associated to any telephone number • Call any phone number and speaks text or sound file to the person. • Instantly determines the distance between two U.S. ZIP codes. • Get historical end of day data for U.S. stock options
A B2C Case Study – Call a Cab • The E-Business 1.0 experience • iQTaxi by qSent.com in 2001 • RPC-style WS provided for 3rd party integration
A B2C Case Study –Call a Cab (cont’d) • Uber: An E-Business 2.0 experience • Made to the news in 2011 • Mash-up w/ GoogleMap for real-time interactions
How to Create a WS – in Java? • Resources the you will need • Java Enterprise Edition (JEE 7) • A Java Application Server (such as GlassFish 4) • A Web Server (such as Apache 2.4) • Ideally an IDE for JEE (such as NetBeans 7.4) • Design decisions to make before coding • Operations to provide get name & say hello • Message format to use SOAP
Five Steps to Completion • Creating a Web Application project • An umbrella for a web, source, and WS folders • Adding a Web Service class w/ a desired name • Defining the Web Service • Specify service and method names, as well as parameters • Publishing and testing the Web Service • Creating a client app to consume the WS
Five Steps … - Testing WS on localhost http://localhost:8080/HelloWS/
A Hello World Web Service Service Consumer