Creating & Consuming Web Services MIS 424 MIS 424 Professor Sandvig Professor Sandvig
Overview – Web Services What are Web Services? Benefits Who is using them Using in.NET –How to create –How to consume
What are Web Services? Web services allow applications to communicate with each other via Internet Islands of data Huge databases –Every large organization –Can’t communicate, share Between organizations Within organizations
What are Web Services? Underlying Technologies –XML Defines data content –SOAP Simple object access protocol –Protocol rules Advantage –HTTP: name-value pairs –SOAP: data relationships Data types Both are W3.org standards –Supported by all major vendors
Why Now? Historically –Physical distance –Small data pipelines Now –Internet, fiber optics, … –Distance not a problem Recent: mid-1990’s Limitation –Need common language & protocols Solution –Web Services: XML & Soap
Who is using? Amazon –Retrieve shipping info –Expose product database UPS –Shipping status, pricing information, etc. Google –Expose database –Tap creativity of programmers Ideas for free Ideas for free Others?? –Difficult to tell, background process Overstock.com web site
Using Web Services in.NET Web Service Namespaces –Implements XML & SOAP technologies –Dozens of classes High level Handle messy details –MSDN Documentation Documentation Heavily promoted functionality of.NET
Using Web Services Two roles: –Create Expose your data/application to other –Consume Utilize web services offered by others
Creating Web Services Visual Studio: –Add new item: Web Service.asmx file
Creating Web Service Default.asmx file:
Creating Web Services Example:Testing –Via HTTP Request.asmx file –CreateWebService.asmx, (source.doc) CreateWebService.asmxsourceCreateWebService.asmxsource
Consuming Web Service Create proxy –Visual Studio 1. Add service reference… 2. Paste in web service description language (wsdl) –VS creates classes that utilize service 3. Use like any other classes
Consuming Web Service Visual Studio Paste web service URL
Consuming Web Service WSDL returns service description: –Give descriptive name and click OK
Consuming Web Service Visual Studio creates class (proxy) representing web service Adds info to web.config
Consuming Web Services Service now represented by class Service methods visible via Intellisense
Consuming Web Service Example: –ConsumeWebService.aspx ConsumeWebService.aspx –.asmx files can handle AJAX calls See assignment 4 –ObjectDataSource control: Use VS wizard to select web service class
Summary – Web Services Allow applications to communicate –Connect islands of data Based upon W3 standards.NET support –Very easy to publish & consume