Web Services Raj Sunderraman CSC 8711 Computer Science
Web Services Raj Sunderraman CSC 8711 Computer Science Department Georgia State University (Adapted from Mark Sapossnek (Boston Uni. ) presentation)
Web Services Overview Internet Business Processes Span Companies
Web Services Overview Technology Fabric Must Span Companies Too
Web Services Overview Drivers w Companies, suppliers, partners, and customers must be able to work together n n n Faster than ever before Over the Internet Or risk “death by isolation” w Leverage Internet cost structure
Web Services Overview Possible Solutions w Distributed computing w Web sites (portals) w Web Services
Web Services Overview Distributed Computing w Client/server model n n Doesn‘t scale Not secure w Distributed object model n n n Components: packaging and interoperability Remoting: remote method invocation COM, CORBA, Java RMI and EJB l l l Not Internet-friendly Interoperability issues: poor/non-existent standards Tightly coupled: still doesn‘t scale
Web Services Overview Distributed Computing w 3 -tier Application Architecture n Great way to build scalable Web applications w But such applications are silos n n Integration is an afterthought They can be integrated behind the firewall l n Even that can be a problem They do not provide a way to integrate across the firewall (i. e. over the Internet)
Web Services Overview Portals Ads Mail Other Svcs Calendar Weather Finance News
Web Services Overview Portal Limitations w w w No standard way to expose functionality Integration is expensive and error-prone Hard to outsource Not designed to be used outside original scope The problem? n n n HTML is designed for presentation to people Can’t repurpose it in a general, reliable way Don’t even think about screen scraping
Web Services Overview What Is a Web Service? w The solution? Web Services! w A Web Service exposes functionality to a consumer n n n Over the Internet or intranet A programmable URL Functions you can call over the Internet w Based on Web standards n HTTP, XML, SOAP, WSDL, UDDI, with more to come w Can be implemented in any language on any platform w Black boxes n Component-like, reusable
Web Services Overview What Is a Web Service? w A Web Service combines the best features of distributed computing and portals and eliminates the worst n n Provides a mechanism for invoking methods remotely Uses Web standards (e. g. HTTP, XML) to do so
Web Services Overview What Is a Web Service? w Web Services allow you to interconnect: n n Different companies Many/any devices Applications Different clients l Not just browsers w Distribution and integration of application logic w Enable the programmable Web n Not just the purely interactive Web w Web Services are loosely coupled
Web Services Overview What is a Web Service? w w w New paradigm for Internet development Deliver applications as services Richer, customer-driven experience Continuous delivery of value/bits Third-generation Internet
Web Services Overview Evolution of the Web HTML, XML Generation 1 Generation 2 Generation 3 Static HTML Web Applications Web Services
Web Services Overview Benefits w Everyone n n n Leverage existing infrastructure “Build or buy” development decisions Minimize development time/costs w Enterprises n n Integration imperative Dynamic, easy B 2 B relationships w New Web-based businesses n n n Greater personalization New services/new revenue streams Be “everywhere” vs. single destination
Web Services Overview Possibilities w Scenario: Planning a trip n n n Go to Expedia site (or Travelocity, or …) Log in. Find the flights you want l l n n Don’t have to reenter seat/meal/airline/frequent flyer/… info System can find lowest price fare by looking at your calendar(s) Purchase tickets w/o entering credit card # Flight info automatically added to your calendar and your spouse’s calendar Book rental car/hotel w/your preferences; added to calendar On day of trip get notified of flight status via email/toast/pager/cell phone
Web Services Overview Application Model Partner Web Service Other Web Services Internet + XML End Users Your. Company. com Application Business Logic Tier Data Access and Storage Tier Other Applications Partner Web Service
Web Services Overview Sample Web Services w E-commerce: order books, office supplies, other products w Track packages: UPS, Fed. Ex w Weather w Maps w Telephone redirection, customizable rules and messages
Agenda w w w Web Services Overview Underlying Technologies Developing a Web Service Consuming Web Services Miscellaneous. NET My Services
Underlying Technologies XML Is the Glue y IP / P C T og l o n h Tec Inn Connectivity ov ati FTP, on E-ma il, Go pher Connect the Web L M T H Presentation Web Pa ges Browse the Web XML Connecting Applications Web Se rvice s Program the Web
Underlying Technologies Web Services Stack (Standards) Directory: Publish & Find Services: UDDI Description: Formal Service Descriptions: WSDL Wire Format: Service Interactions: SOAP Universal Data Format: XML Ubiquitous Communications: Internet Simple, Open, Broad Industry Support
Underlying Technologies Web Services Stack w Discovery n Directory allows potential clients to locate relevant Web Services l n UDDI A Description language defines the format of methods provided by a Web Service l WSDL
Underlying Technologies Web Services Stack UDDI Description WSDL http: //www. ibuyspy. com/ibuyspycs/Instant. Order. asmx? wsdl Request Service Description Return Service Description (XML) Wire Format Request Service Return Service Response (XML) SOAP Web Service Client Link to Discovery Document (XML) UDDI or other directory service Directory http: //www. uddi. org Locate a Service
Underlying Technologies Web Service Wire Format w The Web Service Wire Format specifies how specific messages are exchanged n n n HTTP-GET HTTP-POST SOAP w HTTP-GET and HTTP-POST use a minimal HTTP interface to invoke Web Services n Limited support for data types w SOAP provides a robust HTTP/XML interface n Extensive support for data types
XML Overview XML Basics w XML is designed to represent and transfer structured data n In HTML: <p>Jan 15, 2000 </p> n In XML: <Order. Date>Jan 15, 2000</Order. Date> w XML does not display or transform data n n XML separates data from formatting and transforming HTML and XML are both derived from SGML l In different ways
XML Overview XML Syntax w XML is composed of tags and attributes n Tags can be nested l Representing entities, entity properties, and entity hierarchy <ROOT> <Orders Order. ID="10643" Customer. ID="ALFKI" Employee. ID="6" Order. Date="1997 -08 -25 T 00: 00" Required. Date="1997 -09 -22 T 00: 00" Shipped. Date="1997 -09 -02 T 00: 00" /> </ROOT>
XML Overview XML Schemas w XML schemas describe the structure of an XML document n XML schemas describe the tag and attribute specifications l n n Simple and compound data types XML schemas also describe constraints on the contained text XML schemas and the DTD are mutually exclusive
SOAP Overview w A lightweight protocol for exchanging information in a distributed, heterogeneous environment n It enables cross-platform interoperability w Interoperable n n n OS, object model, programming language neutral Hardware independent Protocol independent w Works over existing Internet infrastructure
SOAP Overview w Guiding principle: “Invent no new technology” w Builds on key Internet standards n n n SOAP ≈ HTTP + XML SOAP 1. 2, W 3 C working draft Tutorial: http: //www. w 3. org/TR/2002/WD-soap 12 -part 0 -20020626/ w The SOAP specification defines: n n The SOAP message format How to send messages How to receive responses Data encoding
SOAP Is Not… w Objects-by-reference n Message-oriented w Complicated n n Doesn’t try to solve every problem in distributed computing Can be easily implemented
SOAP The HTTP Aspect w SOAP requests are HTTP POST requests POST /Web. Calculator/Calculator. asmx HTTP/1. 1 Content-Type: text/xml SOAPAction: “http: //tempuri. org/Add” Content-Length: 386 <? xml version=“ 1. 0”? > <soap: Envelope. . . >. . . </soap: Envelope>
SOAP Message Structure SOAP Message The complete SOAP message Headers Protocol binding headers SOAP Envelope <Envelope> encloses payload SOAP Headers SOAP Body Message Name & Data <Header> encloses headers Individual headers <Body> contains SOAP message name XML-encoded SOAP message name & data
SOAP Message Format w An XML document using the SOAP schema: <? xml version=“ 1. 0”? > <soap: Envelope. . . > <soap: Header. . . >. . . </soap: Header> <soap: Body> <Add xmlns=“http: //tempuri. org/”> <n 1>12</n 1> <n 2>10</n 2> </Add> </soap: Body> </soap: Envelope>
SOAP Server Responses w Server replies with a “result” message: HTTP/1. 1 200 OK. . . Content-Type: text/xml Content-Length: 391 <? xml version=“ 1. 0”? > <soap: Envelope. . . > <soap: Body> <Add. Result xmlns=“http: //tempuri. org/”> <result>28. 6</result> </Add. Result> </soap: Body> </soap: Envelope>
SOAP Encoding Complex Data w Data structures are serialized as XML: <soap: Envelope. . . > <soap: Body> <Get. Stock. Data. Result xmlns=“http: //tempuri. org/”> <result> <Description>Plastic Novelties Ltd</Description> <Price>129</Price> <Ticker>PLAS</Ticker> </result> </Get. Stock. Data. Rseult> </soap: Body> </soap: Envelope>
SOAP Security and Features w Builds on HTTP Security n HTTPS w Developers / IT choose which methods to expose explicitly w Does not pass application code w Firewall-friendly w Type safe
SOAP Industry Support w w w w w Sun Microsystems Develop. Mentor Inc. Digital Creations IONA Technologies PLC Jetform Object. Space Inc. Rockwell Software Inc. SAP Compaq w w w w w Microsoft Rogue Wave Software Inc. Scriptics Corp. Secret Labs AB User. Land Software Inc. Zveno Pty. Ltd. IBM Hewlett Packard Intel
SOAP Example of a SOAP Request POST /Stock. Quote HTTP/1. 1 Host: www. stockquoteserver. com Content-Type: text/xml; charset="utf-8" Content-Length: nnnn SOAPAction: "Some-URI“ <SOAP-ENV: Envelope xmlns: SOAPENV="http: //schemas. xmlsoap. org/soap/envelope/" SOAP-ENV: encoding. Style = "http: //schemas. xmlsoap. org/soap/encoding/"> <SOAP-ENV: Body> <m: Get. Last. Trade. Price xmlns: m="Some-URI"> <symbol>DIS</symbol> </m: Get. Last. Trade. Price> </SOAP-ENV: Body> </SOAP-ENV: Envelope>
SOAP Example of a 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: encoding. Style= "http: //schemas. xmlsoap. org/soap/encoding/"/> <SOAP-ENV: Body> <m: Get. Last. Trade. Price. Response xmlns: m="Some-URI"> <Price>34. 5</Price> </m: Get. Last. Trade. Price. Response> </SOAP-ENV: Body> </SOAP-ENV: Envelope>
SOAP Example of a SOAP Error HTTP/1. 1 500 Internal Server Error 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> <SOAP-ENV: Fault> <faultcode> SOAP-ENV: Must. Understand </faultcode> <faultstring>SOAP Must Understand Error </faultstring> </SOAP-ENV: Fault> </SOAP-ENV: Body> </SOAP-ENV: Envelope>
WSDL Web Services Description Language w XML schema for describing Web Services 1. Service interface definition – 2. Abstract semantics for Web Service implementation definition – Concrete end points and network addresses where Web Service can be invoked w Clear delineation between abstract and concrete messages
WSDL Schema Interface Implementation <definitions> <import> <types> <service> <message> <port. Type> <binding> <port>
WSDL Schema Interface <definitions> <import> <types> <message> • <definitions> are root node of WSDL • <import> allows other entities for inclusion • <types> are data definitions xsd • <message> defines parameters of a Web Service function <port. Type> • <port. Type> defines input and output operations <binding> • <binding> specifies how each message is sent over the wire
WSDL Schema Implementation • <service> specifies details about the implementation • <port> contains the address itself <definitions> <import> <service> <port>
WSDL Elements w Open – allows for other namespaces and thus highly extensible w Ability to import other schemas & WSDL w Provides “recipe” for Web Services w Provides both interface and implementation details w Allows for separation of the two
WSDL Example w Demo: My. Hello service on db. gsu. edu http: //db. gsu. edu: 8080/hello-jaxrpc/hello? WSDL
UDDI Overview w UDDI = Universal Description, Discovery, and Integration w Industry Initiative to address discovery n A registration database for Web Services w Specifications n n Schema for service providers and descriptions API for publishing and searching Developed on industry standards (XML, HTTP, TCP/IP, SOAP) Applies to both XML and non-XML services w Implementation n Public and private instances of specification
UDDI The Vision Advanced Discovery via Portals and Marketplaces Marketplace UDDI Registries and Protocol Marketplace Search Portal Business Users Technical Users
Resources w Web Services Essentials http: //msdn. microsoft. com/library/default. asp? URL= /library/techart/webservicesessentials. htm w SOAP http: //msdn. microsoft. com/soap w SOAP Specification http: //www. w 3. org/TR/SOAP/ w Don Box on SOAP http: //msdn. microsoft. com/msdnmag/issues/0300/soap. asp w Introduction to SOAP http: //www. w 3. org/2000/xp/Group/Admin/minutes-oct 1100 /soap-xp-wg_files/frame. htm
Resources w WSDL Specification http: //www. w 3. org/TR/wsdl w Sun Microsystems: http: //java. sun. com/webservices w IBM: http: //www. ibm. com/webservices w Microsoft: http: //www. microsoft. com/webservices w A Quick Introduction to WSDL http: //msdn. microsoft. com/library/default. asp? url=/library /enus/soap/htm/soap_overview_72 b 0. asp? frame=true w UDDI http: //www. uddi. org http: //uddi. microsoft. com
Resources w Hail. Storm http: //www. microsoft. com/net/hailstorm. asp w Building Web Services with SOAP and ASP. NET http: //msdn. microsoft. com/msdnmag/issues/01/02/Web. C omp/webcomp. asp w GXA Web Services Specifications http: //msdn. microsoft. com/library/default. asp? url=/library/enus/dnsrvspec/html/wsspecsover. asp? frame=true
- Slides: 51