ASP'NET AJAX with Web Services - PowerPoint PPT Presentation

1 / 26
About This Presentation
Title:

ASP'NET AJAX with Web Services

Description:

Participates in developer community events in the Southeast ... Decorated with WebMethod attribute. More on Page Methods. All types will be JSON serialized ... – PowerPoint PPT presentation

Number of Views:558
Avg rating:3.0/5.0
Slides: 27
Provided by: NoahS8
Category:

less

Transcript and Presenter's Notes

Title: ASP'NET AJAX with Web Services


1
ASP.NET AJAX with Web Services
  • Noah Subrin
  • Atlanta MS Pros
  • Cutting Edge
  • VB .Net Study Group
  • November 5, 2007

2
Speaker Biography
  • Technical Lead SRA International
  • MCSD and MCSD .Net
  • Participates in developer community events in the
    Southeast
  • Published several articles on www.sswug.org

3
What we will discuss tonight
  • Brief ASP .Net AJAX 1.0 overview
  • AJAX Programming models
  • Focus on Remote Services
  • Web Services
  • Page Methods
  • Built in APIs

4
Traditional Web Apps
  • Web was originally designed for static pages
  • Todays web is much more interactive.
  • Client issues a request, the server returns HTML
    markup, and the entire page is refreshed
  • Everything is done on the web server

5
AJAX-Enabled Applications
  • AJAX apps use a client side framework to make out
    of band calls to the server
  • AJAX server side framework returns data to the
    customer that is primarily in the form of JSON
    but may be XML or other formats such as RSS, CSV
  • Reduces bandwidth required and UIs are able to
    be redrawn using partial rendering
  • More code is executed on the browser

6
So What is ASP .Net 2.0 AJAX?
  • Server side ASP 2.0 AJAX extensions that are
    installed in global assembly cache (GAC)
  • Client side JavaScript libraries that can be used
    stand alone
  • Visual Studio 2005 or Visual Web Developer are
    not necessary to use server side components (but
    they provide templates)

7
AJAX Programming Models
  • Partial Page Rendering
  • Script Services
  • Local web services
  • Page Methods
  • How to call external web services
  • Authentication services
  • Profile Web services

8
Characteristics of AJAX services
  • REST services (Representational State Transfer)
  • Each URL represents the state of an object
    retrieved using an HTTP verb (GET, POST, PUT)
  • Tied to the platform and domain where they are
    hosted
  • Not SOA in truest sense
  • Who uses REST ? Amazon, Yahoo and many others

9
REST Web Services
  • Predates the WS specs
  • Typically easier to read than SOAP
  • New operation can be exposed without updating web
    reference
  • REST relies on HTTP verbs and URLs to express
    the operation
  • Not a standard (like SOAP) or a protocol (like
    HTTP)
  • Each operation has a distinct URL

10
SOAP Web Services
  • SOAP services are an XML based protocol SOAP
    services need an envelope, message, header, and
    body
  • WSDL to describes the web service API
  • XML Schema describes the call
  • Uses a single URL
  • Can support WS specs

11
AJAX Web Services Demos
  • Expose the web services to clients
  • Calling web services from the client
  • Fire and Forget
  • Returns a Value
  • Takes Parameters
  • Handles an Error
  • Lengthy Operation
  • User Context and method Names
  • Complex Types

12
Why only Local Services?
  • Security implications of cross site calls
  • SOAP is harder to manage from client side
    JavaScript
  • No XML parser is needed
  • Support for JSON serialization which uses
    name-value pairs

13
What about WCF Services?
  • In ASP .Net AJAX 1.0 we are currently unable to
    call WCF services
  • Support for WCF services calls from AJAX in Orcas
    will presumably be enhanced

14
Page Methods
  • Provide ability for client script to call a
    static method in an ASP .Net page as if it were a
    web service.
  • Scoped within a page -cannot be called from a
    different page other than where they are defined
  • Decorated with WebMethod attribute

15
More on Page Methods
  • All types will be JSON serialized
  • Not enabled by default, to enable, we set the
    ScriptManager property EnablePageMethodstrue
  • The page acts as a web service

16
PageMethods Demo
  • Writing to Session object from a PageMethod

17
PageMethods vs AJAX Web Services
  • From PageMethods we can access Session state, ASP
    .Net Cache, and User objects
  • For PageMethods we dont have to create an .asmx
    web service
  • Local Web services are callable from every page
  • Web services are callable by SOAP based clients
  • For both - dont include any critical business
    logic (replay attacks)

18
Calling external web services
  • Not included in ASP .Net AJAX Extensions 1.0
  • New file type .asbx, which is an xml file
  • It contains info on how to connect to a remote
    web service
  • This is a Futures technology but it is possible
    to build manually using WebMethod or PageMethod
  • Client calls its own server local server calls
    a remote server

19
Application Services
  • Forms Authentication
  • Profile Information

20
Forms Authentication
  • We can use the MS AJAX library authentication
    service to verify credentials stored as part of
    the ASP .Net membership application service
  • Server configuration is in web.config
  • Server issues a ticket
  • Client browser needs cookies enabled

21
Forms Authentication Demo
  • Restrict Directory Access
  • JavaScript Functions
  • Web.config settings
  • Membership provider

22
Profiles Web Services
  • The profile service enables you to use the
    ASP.NET profile application service from client
    side JavaScript
  • Must enable the Profile Service in the web.config
  • By default, no profile properties are available.
    For each profile property that you want to make
    available in a client application, add the
    property name to the readAccessProperties
    attribute of the ltprofileServicegt element.

23
Profile Services Demo
  • Adding custom properties to a .Net 2.0 Provider

24
Summary
  • We can create and expose local web services to
    client side JavaScript
  • We can use local web services or PageMethods
  • We used JSON serialization
  • We leveraged callback functions to update the
    pages
  • We can call ASP.Net 2.0 Authentication and
    Profile services from client side JavaScript

25
Additional Resources
  • www.asp.net/ajax
  • SOAP Specification httpwww.w3.org/tr/soap)
  • REST Specification
  • http//www.ics.uci.edu/fielding/pubs/dissertatio
    n/top.htm
  • Introducing Microsoft ASP .Net AJAX by Dino
    Esposito
  • Professional ASP .Net 2.0 AJAX by Matt Gibbs and
    Dan Wahlin

26
Contact Info
  • Email address
  • support _at_federalsystems.net
  • Blog blogs.federalsystems.net
Write a Comment
User Comments (0)
About PowerShow.com