+ All Categories
Home > Documents > ASP.NET AJAX with Web Services

ASP.NET AJAX with Web Services

Date post: 03-Dec-2014
Category:
Upload: sampetruda
View: 1,428 times
Download: 0 times
Share this document with a friend
Description:
 
Popular Tags:
26
ASP.NET AJAX with Web Services Noah Subrin Atlanta MS Pros Cutting Edge VB .Net Study Group November 5, 2007
Transcript
Page 1: ASP.NET AJAX with Web Services

ASP.NET AJAX with Web Services

Noah SubrinAtlanta MS ProsCutting EdgeVB .Net Study GroupNovember 5, 2007

Page 2: ASP.NET AJAX with Web Services

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

Page 3: ASP.NET AJAX with Web Services

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 API’s

Page 4: ASP.NET AJAX with Web Services

Traditional Web Apps

Web was originally designed for static pages

Today’s 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

Page 5: ASP.NET AJAX with Web Services

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 UI’s are able to be redrawn using partial rendering

More code is executed on the browser

Page 6: ASP.NET AJAX with Web Services

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)

Page 7: ASP.NET AJAX with Web Services

AJAX Programming Models

Partial Page Rendering Script Services Local web services Page Methods How to call external web services Authentication services Profile Web services

Page 8: ASP.NET AJAX with Web Services

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

Page 9: ASP.NET AJAX with Web Services

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

URL’s to express the operation Not a standard (like SOAP) or a

protocol (like HTTP) Each operation has a distinct URL

Page 10: ASP.NET AJAX with Web Services

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

Page 11: ASP.NET AJAX with Web Services

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

Page 12: ASP.NET AJAX with Web Services

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

Page 13: ASP.NET AJAX with Web Services

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

Page 14: ASP.NET AJAX with Web Services

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

Page 15: ASP.NET AJAX with Web Services

More on Page Methods

All types will be JSON serialized Not enabled by default, to enable,

we set the ScriptManager property EnablePageMethods=true

The page acts as a web service

Page 16: ASP.NET AJAX with Web Services

PageMethods Demo

Writing to Session object from a PageMethod

Page 17: ASP.NET AJAX with Web Services

PageMethods vs AJAX Web Services

From PageMethods we can access Session state, ASP .Net Cache, and User objects

For PageMethods we don’t 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 - don’t include any critical business logic (replay attacks)

Page 18: ASP.NET AJAX with Web Services

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

Page 19: ASP.NET AJAX with Web Services

Application Services

Forms Authentication Profile Information

Page 20: ASP.NET AJAX with Web Services

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

Page 21: ASP.NET AJAX with Web Services

Forms Authentication Demo

Restrict Directory Access JavaScript Functions Web.config settings Membership provider

Page 22: ASP.NET AJAX with Web Services

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 <profileService> element.

Page 23: ASP.NET AJAX with Web Services

Profile Services Demo

Adding custom properties to a .Net 2.0 Provider

Page 24: ASP.NET AJAX with Web Services

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

Page 25: ASP.NET AJAX with Web Services

Additional Resources www.asp.net/ajax SOAP Specification

http:www.w3.org/tr/soap) REST Specification

http://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm

Introducing Microsoft ASP .Net AJAX by Dino Esposito

Professional ASP .Net 2.0 AJAX by Matt Gibbs and Dan Wahlin

Page 26: ASP.NET AJAX with Web Services

Contact Info

Email address: support @federalsystems.net

o Blog: blogs.federalsystems.net


Recommended