200 likes | 340 Views
Web services are platforms enabling the development of interoperable distributed applications accessible via the web through APIs. This technology facilitates data exchange in various formats like XML and JSON. Companies like Google and eBay provide services using protocols such as SOAP and REST, each offering unique advantages. SOAP is more structured but heavier, while REST is known for its simplicity and lightweight nature. This guide explores service offerings, architectural design, and how users can interact with these web services effectively.
E N D
Web Service 2008-4-21
什么是Web服务? • 建立可互操作的分布式应用程序的平台 • 能够通过Web进行调用的API GET http://localhost/weather.asp?zipcode=20171返回数据:21,晴. 这个页面就可以算作是Web service 了. • 哪些服务? • Google • EBay • 技术手段? • SOAP • REST • … Overview
Computer Human • Shopping • Trading • Research EBay服务提供商提供了哪些服务?
Get a list with keyword “T-shirt” | Search and browse | Shopping web service | Document or WSDL | XML/JSON/SOAP | Parse or use Toolkit XML Sample EBay服务使用者如何使用这些服务?
轻量级,介于TEXT和XML之间 不需要解析器,直接转为JavaScript数组 JSON(JavaScript Object Notation)
AddOrder method SOAP
(JSON) REST EBay服务提供商如何设计服务的架构?
SOAP(Simple Object Access Protocol) • WSDL+UDDI+WS-* • 各个平台提供支持. • 易于设计应用级别的访问接口. • 不依赖于HTTP的多重协议. Including Google, EBay all provide web service using SOAP. • REST(Representational State Transfer) • Resources(N) + POST/PUT/GET/DELETE(CURD)(V) • 资源多重表述(JSON/XML/IMAGE) • REST最大的特点是容易被人理解,不需要额外的工具进行解析. • 早期的web service比较常用SOAP,目前REST日渐流行(Google). • Lightweight. Including Yahoo, delicious, Amazon all provide web service using REST style architecture. SOAP VS REST
公开的有50多种供开发者调用的服务 • GData(Google Data API) • Blogger, Calendar, Picasa, YouTube, Gmail(Atom) • URL • Account, Static Map, Chart • AJAX • Map, Search, Book Search, Checkout • SOAP • AdSense, AdWords • XMPP • GTalk • Toolkit • Gadget, Web Toolkit, Desktop Search, Desktop Gadget, Mashup Editor, Mapplets REST Google服务提供商提供了哪些服务?
Based on Atom 1.0 and RSS 2.0 • Query • Update • Collaboration • Authentication • In the spirit of REST • Resource(URL) • Query->GET • Updates->POST/PUT/DELETE GData
Get a video list(YouTube) GET http://gdata.youtube.com/feeds/api/standardfeeds/top_rated Response: Refer to : http://code.google.com/apis/youtube/developers_guide_protocol.html Google服务使用者如何使用这些服务?
GET Google服务使用者如何使用这些服务?
Add a calendar POST POST: Response: Google服务使用者如何使用这些服务?
Account • GET https://www.google.com/accounts/ClientLogin?accountType=HOSTED_OR_GOOGLE&Email=jondoe@gmail.com&Passwd=north23AZ&service=cl • Response SID=DQAAAGgA...7Zg8CTN LSID=DQAAAGsA...lk8BBbG Auth=DQAAAGgA...dk3fA5N • Static Map • GET http://maps.google.com/staticmap?center=40.714728,-73.998672&zoom=14&size=512x512&maptype=mobile\ &markers=40.702147,-74.015794,blues%7C40.711614,-74.012318,greeng%7C40.718217,-73.998284,redc\ &key=MAPS_API_KEY • Response URL
Load Engine Setting Map Setting Search AJAX Display
AdSense • 针对网站主的一种服务,将广告主投放的广告投放于网站主的网站,以使网站主分享广告收益 • https://www.google.com/api/adsense/v3/AdSenseForContentService?wsdl SOAP
Google Gadgets Editor + Google Gadget API http://code.google.com/apis/gadgets/docs/gs.html#GGE Gadget