Upload
joleen-atkinson
View
216
Download
0
Embed Size (px)
Citation preview
Overview – Web ServicesOverview – Web Services
What are Web Services?What are Web Services?
BenefitsBenefits
Who is using themWho is using them
Using in .NETUsing in .NET– How to createHow to create– How to consumeHow to consume
What are Web Services?What are Web Services?
Web services allow applications to communicate Web services allow applications to communicate with each other via Internetwith each other via Internet
Islands of dataIslands of data
Huge databasesHuge databases– Every large organizationEvery large organization– Can’t communicate, shareCan’t communicate, share
Between organizationsBetween organizations
Within organizationsWithin organizations
What are Web Services?What are Web Services?
Underlying TechnologiesUnderlying Technologies– XMLXML
Defines data contentDefines data content– SOAPSOAP
Simple object access protocolSimple object access protocol– Protocol Protocol rules rules
AdvantageAdvantage– HTTP: name-value pairsHTTP: name-value pairs– SOAP: SOAP:
data relationshipsdata relationshipsData typesData types
Both are W3.org standardsBoth are W3.org standards– Supported by all major vendorsSupported by all major vendors
Why Now?Why Now?
HistoricallyHistorically– Physical distancePhysical distance– Small data pipelinesSmall data pipelines
NowNow– Internet, fiber optics, …Internet, fiber optics, …– Distance not a problemDistance not a problem
Recent: mid-1990’sRecent: mid-1990’s
LimitationLimitation– Need common language & protocolsNeed common language & protocols
SolutionSolution– Web Services: XML & SoapWeb Services: XML & Soap
Who is using?Who is using?
AmazonAmazon– Retrieve shipping infoRetrieve shipping info– Expose product databaseExpose product database
UPSUPS– Shipping status, pricing information, etc.Shipping status, pricing information, etc.
GoogleGoogle– Expose databaseExpose database– Tap creativity of programmersTap creativity of programmers
Ideas for freeIdeas for free
Others??Others??– Difficult to tell, background processDifficult to tell, background process
Overstock.com web site
Using Web Services in .NETUsing Web Services in .NET
Web Service NamespacesWeb Service Namespaces– Implements XML & SOAP technologiesImplements XML & SOAP technologies– Dozens of classesDozens of classes
High levelHigh level
Handle messy detailsHandle messy details
– MSDN DocumentationMSDN Documentation
Heavily promoted functionality of .NETHeavily promoted functionality of .NET
Using Web ServicesUsing Web Services
Two roles:Two roles:– CreateCreate
Expose your data/application to otherExpose your data/application to other
– ConsumeConsumeUtilize web services offered by othersUtilize web services offered by others
Creating Web ServicesCreating Web Services
Visual Studio:Visual Studio:– Add new item: Web ServiceAdd new item: Web Service
.asmx file.asmx file
Creating Web ServicesCreating Web Services
Example:Example:
TestingTesting– Via HTTPVia HTTP
Request .asmx fileRequest .asmx file
– CreateWebService.asmx, (source .doc)CreateWebService.asmx, (source .doc)
Consuming Web ServiceConsuming Web Service
Create proxyCreate proxy– Visual StudioVisual Studio
1.1. Add service reference…Add service reference…2.2. Paste in web service Paste in web service
description language (wsdl)description language (wsdl)– VS creates classes that utilize VS creates classes that utilize
serviceservice
3.3. Use like any other classesUse like any other classes
Consuming Web ServiceConsuming Web Service
Visual StudioVisual Studio
Paste web Paste web service URLservice URL
Consuming Web ServiceConsuming Web ServiceWSDL returns service description:WSDL returns service description:– Give descriptive name and click OKGive descriptive name and click OK
Consuming Web ServiceConsuming Web Service
Visual Studio creates class Visual Studio creates class (proxy) representing web (proxy) representing web serviceservice
Adds info to web.config Adds info to web.config
Consuming Web ServicesConsuming Web Services
Service now represented by classService now represented by class
Service methods visible via IntellisenseService methods visible via Intellisense
Consuming Web ServiceConsuming Web Service
Example: Example: – ConsumeWebService.aspxConsumeWebService.aspx
– .asmx files can handle AJAX calls.asmx files can handle AJAX callsSee assignment 4 See assignment 4
– ObjectDataSource control:ObjectDataSource control:Use VS wizard to select web service classUse VS wizard to select web service class