ASP Web Services - PowerPoint PPT Presentation

1 / 36
About This Presentation
Title:

ASP Web Services

Description:

Build web services (credit card authorization) Programmable application logic (.asmx) ... How do we find (or discover) web services? ... – PowerPoint PPT presentation

Number of Views:191
Avg rating:3.0/5.0
Slides: 37
Provided by: robh164
Category:
Tags: asp | asp | card | discover | hosting | net | services | web

less

Transcript and Presenter's Notes

Title: ASP Web Services


1
ASP Web Services Rob Howard Microsoft
Corporation
2
Agenda
  • Web service overview
  • Building web services with .NET technologies
  • Description and discovery
  • Building the proxy
  • Tips and tricks
  • Resources and QA

3
What is a Web Service?
  • A web service is programmatically available
    application logic exposed over the Internet
  • Available to a variety of clients (platform
    independent)
  • E.g. stock quote, weather, and authentication
    services
  • Makes building distributed applications less
    difficult
  • Most common metaphor for accessing information is
    through a web browser
  • Traditional web applications don't expose any
    application logic (Microsoft's Money Central)

4
What is a Web Service?
A web service is programmable application logic
accessible via standard Web protocols
HTML
5
Common Questions/Issues
  • How do you publish the location of a web service?
  • How do you describe a web service?
  • What protocols does it support?
  • What data types does it use?
  • Challenges
  • Simple and fast programming model
  • Understanding of transport protocols,
    serialization, discovery, etc. are challenges
    most developers don't have time to deal with
  • Solutions today still have complexities
  • Microsoft SOAP Toolkit
  • IBM (SOAP Toolkit)
  • Etc.

6
Microsoft Web Services
  • Built on standard web protocols
  • HTTP and XML
  • Technology innovations for web services
  • SOAP (Simple Object Access Protocol)
  • Explicit serialization protocol (HTTP XML
    description) used in service exchanges
  • SCL (SOAP Contract Language)
  • XML document describing the location and
    interfaces a particular service supports the
    client's contract
  • DISCO (Discovery)
  • XML document describing (URI) of service

7
Using ASP
  • ASP is a simple, consistent, and powerful web
    application development paradigm
  • Build web pages (microsoft.com)
  • Traditionally browser targeted (.aspx)
  • Build web services (credit card authorization)
  • Programmable application logic (.asmx)
  • Uses SOAP, SCL, and DISCO
  • ASP makes building web services easy!

8
ASP .NET Web Services
  • File extension is .asmx (subject to change)
  • Source file (text and notepad accessible) is
    compiled at run-time
  • .asmx file can either contain application logic
    or point to .NET assembly/class
  • You programmatically determine what is web
    service accessible

9
ASP .NET Web Services
  • Part of the ASP application model
  • Must be URL accessible via Internet Information
    Server
  • IIS is host for the ASP HTTP runtime
  • Access to ASP object model (Request, Session,
    Application, etc.)
  • The web service emits no UI
  • The web browser is not the intended client
  • Supports multiple protocols
  • Including SOAP

10
Demo
  • Creating the Fibonacci Web Service

11
.asmx Deconstructed (1 of 5)
  • Modeled after component based application logic
    development
  • You simply author a component and mark the method
    as being a web service
  • Processing Directives
  • Language Supports JScript, VB7, C, and other
    .NET common language runtime languages
  • Class Allows for the definition of the
    application logic in a component, rather than
    within the .asmx file itself

lt_at_ directivevaluegt
lt_at_ language"C" gt lt_at_ language"VB7" gt
12
.asmx Deconstructed (2 of 5)
  • WebMethod attribute
  • C WebMethod
  • VB7 ltWebMethod()gt
  • JScript WebMethodAttribute
  • Declares a particular method of a class as
    publicly accessible as a service

WebMethodpublic method Add(int a, int b)...
13
.asmx Deconstructed (3 of 5)
  • WebMethod attribute
  • The modifier public is orthogonal to the web
    service modifier WebMethod - otherwise, all
    public methods and properties would be accessible
  • Such as ToString()
  • Enables access to session state and transactions

WebMethod(EnableSessionStatetrue) WebMethod(Tr
ansactionTransaction.Required)
14
.asmx Deconstructed (4 of 5)
  • Access to ASP application services
  • Session, application state, server variables,
    etc.

WebMethodpublic int HitCounter get
return (int) Application"HitCounter"
15
.asmx Deconstructed (5 of 5)
  • You develop one application model (ASP) and
    expose your application logic through either web
    pages or web services
  • Both share
  • Common application logic
  • application logic developed to display stock
    quote values is the same
  • Consistency
  • programming framework is identical (leverage your
    existing skill ASP pages web services)

16
Testing a Web Service
  • Web service itself emits no UI
  • ASP provides .aspx page template for web service
    for testing purposes
  • Accessible through HTML 3.2 browser
  • Uses HTML forms to allow interaction with web
    service

17
Testing a Web Service
  • Template page is named
  • DefaultSDLHelpGenerator.aspx
  • Accessible at (directory to change)
  • system drive\WinNT\ComPlus\v2000.14.1812\
  • Alternate template page can be named via
    config.web entry
  • ltsdlHelpGenerator href"DefaultSdlHelpGenerator.as
    px"/gt

18
Demo
  • Accessing a service through the browser

19
Supported Protocols (HTTP-Get/Post)
  • HTTP-GET and HTTP-POST
  • Encodes data with URL via either HTTP
  • GET Data sent as part of URL
  • POST Data sent in HTTP message body
  • Support simple types (int, string, enum, arrays)
  • Returns data as a simple XML document

20
Supported Protocols (SOAP)
  • SOAP (Simple Object Access Protocol)
  • Serialization format for request/response
    semantics using XML and HTTP as transport
  • Data is sent via POST (or M-POST)
  • Extensible XML document (Envelope, Encoding
    Rules, RPC)
  • Supports complex and simple types (structs,
    datasets, classes)

21
SOAP Contract Language (SCL)
  • Clients need a contract to understand what the
    service is providing
  • COM used IDL (Interface Definition Language)
  • Web Services use SCL
  • SCL is an XML document that describes
  • Supported service transports SOAP, HTTP-GET,
    HTTP-POST
  • Invocation Semantics How requests are made and
    how responses are sent

22
SOAP Contract Language (SCL)
  • SCL and service do not have to exist on the same
    server
  • Allows clients to build strongly typed proxies
  • Programmatically describes interfaces, methods,
    and properties that are exposed as web services
  • .NET SDK PDC builds (including MSDN pre-release)
    refer to SDL
  • SDL (Service Description Language) is predecessor
    to SCL

23
DISCO (Discovery)
  • How do we find (or discover) web services?
  • DISCO XML document that contains references to
    the SCL location for web services
  • Typically lives at the root of a web application
  • Not limited to web services
  • Outlines a "discovery algorithm"
  • HTTP request to URL
  • Application responds with document (either XML or
    HTML)
  • Response is either the DISCO document or an HTML
    document with a pointer to the DISCO document

24
DISCO (Discovery)
  • Place a link in the default site document
  • ltlink type'text/xml' rel'alternate'
    href'some.disco'/gt

ltdiscodiscoverygt ltsclcontractRef
ref'myl.sdl'gt ltsclcontractRef ref'my2.sdl'
docRef'my.htm'gt lt/discodiscoverygt
25
Demo
  • Discovering IBuySpy.com
  • Viewing the SCL

26
Consuming a Web Service
  • Several options for clients to consume web
    services
  • .NET clients can use Visual Studio.NET
  • .NET (SDK) clients can use WebServiceUtil.exe
  • Other platforms can simply interpret XML

27
WebServiceUtil.exe
  • Command line tool that comes with the .NET SDK
  • Used to build client .NET proxy class from the
    SCL document of a web service
  • Classes
  • are strongly typed
  • can be asynchronous
  • can be created in Jscript, C, or VB7 simply by
    specifying a command line setting
  • The tool can also generate
  • SCL file from a given .NET class
  • Defined server .NET class from an SCL

28
Demo
  • Build and use proxy class

29
Web Services (In Practice)
Design-Time or Dynamic
Runtime
30
Tips and Tricks
  • Know and understand the supported data types
  • Don't send unnecessary data (such as an image)
    when you can send a URL
  • Eliminate latency in the server first
  • Use the ASP Cache API where possible
  • Build the service to be asynchronous if the
    potential exists to block other work

31
Tips and Tricks
  • Handle client errors when the server is
    unavailable
  • Cache data from the service where possible,
    rather than requesting the same data 100 times
  • Be efficient about the number of requests for
    dynamic data
  • collapse multiple web service methods into one
  • Read the SOAP, DISCO, and SCL specs
  • Stay tuned for more books from Wrox!

32
Summary
A programmable application component accessible
via standard Web protocols
33
Summary
  • Microsoft provides the leading platform for
    building web applications and services today
  • Great support for XML, HTTP, HTML
  • Full extensibility enables developers to support
    the latest protocols
  • The new .NET platform makes building and using
    web services automatic just part of
    the framework

34
Resources
  • Wrox Press "A Preview of ASP"
  • Chapter 5 covers ASP Web Services
  • Web sites
  • http//msdn.microsoft.com/net/
  • http//www.asptoday.com
  • http//www.develop.com/dm/default.asp
  • http//www.aspng.com/aspng/index.aspx

35
Terminology
  • .asmx
  • ASP application file for web services
  • Assembly
  • A unit of deployment in .NET
  • Assemblies contain classes (application logic)
  • DISCO
  • Resource file that provides a discovery mechanism
    for web services
  • SCL (SOAP Contract Language)
  • Contract that describes a web service
  • SDL (Service Description Language) was
    predecessor to SCL
  • SOAP (Simple Object Access Protocol)
  • RPC serialization through XML and HTTP

36
Questions? Rob Howard Microsoft Corporation
Write a Comment
User Comments (0)
About PowerShow.com