building and using web services with asp.net rob howard program manager.net framework team microsoft...

21
Building and Using Building and Using Web Services with Web Services with ASP.NET ASP.NET Rob Howard Rob Howard Program Manager Program Manager .NET Framework Team .NET Framework Team Microsoft Corp. Microsoft Corp.

Upload: kieran-coxson

Post on 15-Jan-2016

221 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Building and Using Web Services with ASP.NET Rob Howard Program Manager.NET Framework Team Microsoft Corp

Building and Using Building and Using Web Services with Web Services with ASP.NETASP.NET

Rob HowardRob HowardProgram ManagerProgram Manager.NET Framework Team.NET Framework TeamMicrosoft Corp.Microsoft Corp.

Page 2: Building and Using Web Services with ASP.NET Rob Howard Program Manager.NET Framework Team Microsoft Corp

AgendaAgenda

OverviewOverview Standards BasedStandards Based Building Web ServicesBuilding Web Services Using Web ServicesUsing Web Services Beyond the BasicsBeyond the Basics Web Service SecurityWeb Service Security SummarySummary

Page 3: Building and Using Web Services with ASP.NET Rob Howard Program Manager.NET Framework Team Microsoft Corp

What is a Web Service?What is a Web Service? Browser is the most common tool for Browser is the most common tool for

accessing information on the Internetaccessing information on the Internet Web browser is not enough…Web browser is not enough… Devices, etc.Devices, etc.

A web service is programmable A web service is programmable application logic accessible via application logic accessible via standard Web protocolsstandard Web protocols Programmable… Programmable…

Available to a variety of clients (platform independent)Available to a variety of clients (platform independent)

Standard protocols…Standard protocols… Network level interoperabilityNetwork level interoperability

Page 4: Building and Using Web Services with ASP.NET Rob Howard Program Manager.NET Framework Team Microsoft Corp

Common Questions/IssuesCommon Questions/Issues How do you publish the location of a How do you publish the location of a

web service?web service? How do you describe a web service?How do you describe a web service?

What protocols does it support?What protocols does it support? What data types does it use?What data types does it use?

ChallengesChallenges Programming modelProgramming model Understanding of protocols, serialization, Understanding of protocols, serialization,

discovery, etc. discovery, etc. Solutions today still have complexities:Solutions today still have complexities:

Microsoft SOAP ToolkitMicrosoft SOAP Toolkit IBM (SOAP Toolkit)IBM (SOAP Toolkit)

Page 5: Building and Using Web Services with ASP.NET Rob Howard Program Manager.NET Framework Team Microsoft Corp

Standards BasedStandards Based SOAP (Simple Object Access Protocol)SOAP (Simple Object Access Protocol)

Explicit serialization (HTTP + XML description) Explicit serialization (HTTP + XML description) protocol used in service exchangesprotocol used in service exchanges

WSDL (Web Service Description Language)WSDL (Web Service Description Language) XML document describing the location and XML document describing the location and

interfaces a particular service supports – the interfaces a particular service supports – the client's contractclient's contract

DISCO (Discovery)DISCO (Discovery) XML document describing (URI) of serviceXML document describing (URI) of service

UDDI (Universal Description Discovery and UDDI (Universal Description Discovery and Integration)Integration) Yellow pages directory for servicesYellow pages directory for services

Page 6: Building and Using Web Services with ASP.NET Rob Howard Program Manager.NET Framework Team Microsoft Corp

DiscoveryDiscovery

Let me talk to you (SOAP)Let me talk to you (SOAP)

Web Services (In Practice)Web Services (In Practice)

Design-Time or DynamicDesign-Time or Dynamic RuntimeRuntime

http://yourservice.comhttp://yourservice.com

HTML or XML with link to WSDLHTML or XML with link to WSDL

How do we talk? (WSDL)How do we talk? (WSDL)http://yourservice.com/?WSDLhttp://yourservice.com/?WSDL

XML with service descriptionsXML with service descriptions

http://yourservice.com/svc1http://yourservice.com/svc1

XML/SOAP BODYXML/SOAP BODY

Web Web ServiceService

WebWebService Service

ConsumerConsumer

UDDIUDDI

Find a ServiceFind a Servicehttp://www.uddi.orghttp://www.uddi.org

Link to DISCO or WSDL documentLink to DISCO or WSDL document

Page 7: Building and Using Web Services with ASP.NET Rob Howard Program Manager.NET Framework Team Microsoft Corp

ASP.NET Web ServicesASP.NET Web Services

Goal: Make building web services Goal: Make building web services easyeasy Compiled on first request or pre-compiledCompiled on first request or pre-compiled First class feature of ASP.NETFirst class feature of ASP.NET

File extension is File extension is .asmx.asmx

Write application logicWrite application logic Use features of .NET to enable SOAPUse features of .NET to enable SOAP We’re doing the interop work…We’re doing the interop work…

Page 8: Building and Using Web Services with ASP.NET Rob Howard Program Manager.NET Framework Team Microsoft Corp

ASP.NET Web ServicesASP.NET Web Services

Part of the ASP.NET application modelPart of the ASP.NET application model Web Service is represented by an URLWeb Service is represented by an URL Access to common objects: Request, Access to common objects: Request,

Session, Application, etc.Session, Application, etc. The web service emits no UIThe web service emits no UI

SOAP is for applicationsSOAP is for applications However….However….

Supports multiple protocolsSupports multiple protocols Including SOAPIncluding SOAP Extensible…Extensible…

Page 9: Building and Using Web Services with ASP.NET Rob Howard Program Manager.NET Framework Team Microsoft Corp

Demo: Simple and ComplexDemo: Simple and Complex Demo 1 – Writing a simple serviceDemo 1 – Writing a simple service

AddAdd Demo 2 – Comparing VB and C#Demo 2 – Comparing VB and C#

FibonacciFibonacci Demo 3 – Writing a more complex serviceDemo 3 – Writing a more complex service

Data AccessData Access

Page 10: Building and Using Web Services with ASP.NET Rob Howard Program Manager.NET Framework Team Microsoft Corp

3 Mandatory additions, 1 optional addition3 Mandatory additions, 1 optional addition <%@ WebService class=“[class]" %><%@ WebService class=“[class]" %>

Names the class and/or language usedNames the class and/or language used

Imports System.Web.ServicesImports System.Web.Services Required namespaceRequired namespace

[WebMethod] or <WebMethod()>[WebMethod] or <WebMethod()> Method is ‘web callable’Method is ‘web callable’

WebService base classWebService base class Access ASP.NET intrinsic objectsAccess ASP.NET intrinsic objects

.asmx Deconstructed.asmx Deconstructed

Page 11: Building and Using Web Services with ASP.NET Rob Howard Program Manager.NET Framework Team Microsoft Corp

Http-Get / Http-PostHttp-Get / Http-Post Html forms name/valueHtml forms name/value

SOAP (Simple Object Access Protocol)SOAP (Simple Object Access Protocol) Simple, lightweight XML protocol for Simple, lightweight XML protocol for

exchanging structured and typed exchanging structured and typed information on the Web information on the Web

W3C note (May 8, 2000)W3C note (May 8, 2000) Supported by Microsoft, IBM, and othersSupported by Microsoft, IBM, and others Data is sent via POST (or M-POST) Data is sent via POST (or M-POST) Extensible XML document (Envelope, Extensible XML document (Envelope,

Encoding Rules, RPC)Encoding Rules, RPC)

ProtocolsProtocols

Page 12: Building and Using Web Services with ASP.NET Rob Howard Program Manager.NET Framework Team Microsoft Corp

Using Web ServicesUsing Web Services

Proxy characteristicsProxy characteristics Classes are strongly typedClasses are strongly typed Supports both async and syncSupports both async and sync

Visual Studio.NETVisual Studio.NET Add Web Reference to a ProjectAdd Web Reference to a Project

WebServiceUtil.exeWebServiceUtil.exe Classes can be created in any .NET Classes can be created in any .NET

languagelanguage WSDL file from a given .NET classWSDL file from a given .NET class Defined server .NET class from an WSDLDefined server .NET class from an WSDL

Page 13: Building and Using Web Services with ASP.NET Rob Howard Program Manager.NET Framework Team Microsoft Corp

Demo: Building ProxiesDemo: Building Proxies Demo 1 – Building a Proxy with VS.NETDemo 1 – Building a Proxy with VS.NET

Data AccessData Access Demo 2 – Building a Proxy with Command line Demo 2 – Building a Proxy with Command line

tooltool Data AccessData Access

Page 14: Building and Using Web Services with ASP.NET Rob Howard Program Manager.NET Framework Team Microsoft Corp

Beyond the BasicsBeyond the Basics

Soap HeadersSoap Headers Great way to send out of band dataGreat way to send out of band data Not part of the bodyNot part of the body Similar to HTTP HeadersSimilar to HTTP Headers

XML AttributesXML Attributes Shape the XML to the format you needShape the XML to the format you need XmlAttribute, XmlElement, XmlArrayXmlAttribute, XmlElement, XmlArray SoapAttribute, SoapElement, SoapArraySoapAttribute, SoapElement, SoapArray

Screen ScrapeScreen Scrape Turn any HTML site into a web service*Turn any HTML site into a web service*

Page 15: Building and Using Web Services with ASP.NET Rob Howard Program Manager.NET Framework Team Microsoft Corp

Demo: Beyond the BasicsDemo: Beyond the Basics Demo 1 – Working with SOAP HeadersDemo 1 – Working with SOAP Headers

SimpleSimple Demo 2 – Shaping an XML documentDemo 2 – Shaping an XML document

Order DetailsOrder Details Demo 3 – Screen ScrapingDemo 3 – Screen Scraping

Barnes and NobleBarnes and Noble

Page 16: Building and Using Web Services with ASP.NET Rob Howard Program Manager.NET Framework Team Microsoft Corp

Built-in Security FeaturesBuilt-in Security Features

Data hiding (encryption):Data hiding (encryption): Supports HTTPSSupports HTTPS Use .NET Crypto classes ‘roll your own’Use .NET Crypto classes ‘roll your own’ Beta 1 does not support certificatesBeta 1 does not support certificates

Authentication / AuthorizationAuthentication / Authorization Supports Forms authenticationSupports Forms authentication Supports Windows authenticationSupports Windows authentication Supports ‘roll your own’Supports ‘roll your own’

Page 17: Building and Using Web Services with ASP.NET Rob Howard Program Manager.NET Framework Team Microsoft Corp

Design SuggestionsDesign Suggestions

Know and understand the supported Know and understand the supported data typesdata types

Don't send unnecessary data (such as Don't send unnecessary data (such as an image) when you can send a URLan image) when you can send a URL

Eliminate latency in the server firstEliminate latency in the server first Use caching where possibleUse caching where possible Build the service to be asynchronous if Build the service to be asynchronous if

the potential exists to block other workthe potential exists to block other work

Page 18: Building and Using Web Services with ASP.NET Rob Howard Program Manager.NET Framework Team Microsoft Corp

Design SuggestionsDesign Suggestions

Handle client errors when the server is Handle client errors when the server is unavailableunavailable

Cache data from the service where Cache data from the service where possible, rather than requesting the possible, rather than requesting the same data 100 timessame data 100 times

Be efficient about the number of Be efficient about the number of requests for dynamic data - collapse requests for dynamic data - collapse multiple web service methods into onemultiple web service methods into one

Read the SOAP, DISCO, and WSDL Read the SOAP, DISCO, and WSDL specsspecs

Page 19: Building and Using Web Services with ASP.NET Rob Howard Program Manager.NET Framework Team Microsoft Corp

SummarySummary Building and using web services is .NETBuilding and using web services is .NET

Microsoft provides the leading platform for Microsoft provides the leading platform for building web applications and servicesbuilding web applications and services Great support for XML, HTTP, HTMLGreat support for XML, HTTP, HTML Full extensibility enables developers to support Full extensibility enables developers to support

the latest protocolsthe latest protocols

ASP.NET technology makes writing web ASP.NET technology makes writing web services simpleservices simple Share application logicShare application logic Use existing skills and knowledgeUse existing skills and knowledge Consistent development frameworkConsistent development framework Tool support is incredible!Tool support is incredible!

Page 20: Building and Using Web Services with ASP.NET Rob Howard Program Manager.NET Framework Team Microsoft Corp

ResourcesResources Microsoft ASP.NET Web SiteMicrosoft ASP.NET Web Site

http://www.asp.nethttp://www.asp.net

BooksBooks Wrox - “Preview of ASP+“Wrox - “Preview of ASP+“ Others definitely on the wayOthers definitely on the way

Additional SitesAdditional Sites http://msdn.microsoft.com/http://msdn.microsoft.com/ http://www.4guysfromrolla.com/http://www.4guysfromrolla.com/ http://www.asptoday.comhttp://www.asptoday.com http://www.aspfree.comhttp://www.aspfree.com http://www.aspng.com/http://www.aspng.com/

Page 21: Building and Using Web Services with ASP.NET Rob Howard Program Manager.NET Framework Team Microsoft Corp

Web Services AdoptersWeb Services Adopters