ASP.Net, web services--- asynchronous and synchronous and AJAX By Thakur Rashmi Singh.

Slides:



Advertisements
Similar presentations
Chapter 17: WEB COMPONENTS
Advertisements

Component Patterns – Architecture and Applications with EJB copyright © 2001, MATHEMA AG Component Patterns Architecture and Applications with EJB JavaForum.
6/3/2015eBiquity1 Tutorial on AJAX Anubhav Kale (akale1 AT cs DOT umbc DOT edu)
Latest techniques and Applications in Interprocess Communication and Coordination Xiaoou Zhang.
AJAX Presented by: Dickson Fu Dimas Ariawan Niels Andreassen Ryan Dial Jordan Nielson CMPUT 410 University of Alberta 2006.
Web Development Using ASP.NET CA – 240 Kashif Jalal Welcome to week – 1.1 of…
Microsoft ASP.NET AJAX - AJAX as it has to be Presented by : Rana Vijayasimha Nalla CSCE Grad Student.
Chapter 11 ASP.NET JavaScript, Third Edition. 2 Objectives Learn about client/server architecture Study server-side scripting Create ASP.NET applications.
Chapter 12 Extending Web Applications. ASP.NET 2.0, Third Edition2.
1 Thread Pools. 2 What’s A Thread Pool? A programming technique which we will use. A collection of threads that are created once (e.g. when server starts).
Fundamentals of Python: From First Programs Through Data Structures
1 Web Services Visual C# 2008 Step by Step Chapter 30.
COMPUTER TERMS PART 1. COOKIE A cookie is a small amount of data generated by a website and saved by your web browser. Its purpose is to remember information.
Part or all of this lesson was adapted from the University of Washington’s “Web Design & Development I” Course materials.
Joe Hummel, PhD Dept of Mathematics and Computer Science Lake Forest College Lecture 8: WebForms — Web-based.
.NET, and Service Gateways Group members: Andre Tran, Priyanka Gangishetty, Irena Mao, Wileen Chiu.
INTRODUCTION TO WEB DATABASE PROGRAMMING
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
Chris Pinski.  History  What is Ajax  Who uses Ajax  Underlying Technologies  SE Aspect  Common Problems  Conclusion.
CSCI 6962: Server-side Design and Programming Course Introduction and Overview.
Ajax (Asynchronous JavaScript and XML). AJAX  Enable asynchronous communication between a web client and a server.  A client is not blocked when an.
XML Web Services in Visual Studio.NET Peter Ty Developer Evangelist.NET and Developer Group.
Architecture Of ASP.NET. What is ASP?  Server-side scripting technology.  Files containing HTML and scripting code.  Access via HTTP requests.  Scripting.
JavaScript & jQuery the missing manual Chapter 11
XForms: A case study Rajiv Shivane & Pavitar Singh.
Basics of Web Databases With the advent of Web database technology, Web pages are no longer static, but dynamic with connection to a back-end database.
ASP.NET + Ajax Jesper Tørresø ITNET2 F08. Ajax Ajax (Asynchronous JavaScript and XML) A group of interrelated web development techniques used for creating.
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
1 Web Services Distributed Systems. 2 Service Oriented Architecture Service-Oriented Architecture (SOA) expresses a software architectural concept that.
AJAX Without the “J” George Lawniczak. What is Ajax?
C Copyright © 2009, Oracle. All rights reserved. Appendix C: Service-Oriented Architectures.
XP New Perspectives on XML, 2 nd Edition Tutorial 10 1 WORKING WITH THE DOCUMENT OBJECT MODEL TUTORIAL 10.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
Node.js - What is Node.js? -
11 Web Services. 22 Objectives You will be able to Say what a web service is. Write and deploy a simple web service. Test a simple web service. Write.
Putting it all together Dynamic Data Base Access Norman White Stern School of Business.
Chapter 6 Server-side Programming: Java Servlets
1 (Worker Queues) cs What is a Thread Pool? A collection of threads that are created once (e.g. when a server starts) That is, no need to create.
1 Geospatial and Business Intelligence Jean-Sébastien Turcotte Executive VP San Francisco - April 2007 Streamlining web mapping applications.
Introducing ASP.NET 2.0. Internet Technologies WWW Architecture Web Server Client Server Request Response Network HTTP TCP/IP PC/Mac/Unix + Browser (IE,
Active Server Pages (ASP), also known as Classic ASP or ASP Classic, was Microsoft's first server-side script engine for dynamically generated web pages.
XML Web Service. Overview of XML Web Service ASP.NET XML Web services enable you to remotely access the properties and methods of classes across a network.
ASP.NET (Active Server Page) SNU OOPSLA Lab. October 2005.
ASP.NET Web Services.  A unit of managed code installed under IIS that can be remotely invoked using HTTP.
Web Technologies Lecture 8 Server side web. Client Side vs. Server Side Web Client-side code executes on the end-user's computer, usually within a web.
JS (Java Servlets). Internet evolution [1] The internet Internet started of as a static content dispersal and delivery mechanism, where files residing.
 Previous lessons have focused on client-side scripts  Programs embedded in the page’s HTML code  Can also execute scripts on the server  Server-side.
Understanding Web Applications Lesson 4. Objective Domain Matrix Skills/ConceptsMTA Exam Objectives Understanding Web Page Development Understand Web.
CSI 3125, Preliminaries, page 1 SERVLET. CSI 3125, Preliminaries, page 2 SERVLET A servlet is a server-side software program, written in Java code, that.
Introduction and Principles Web Server Scripting.
Web Services Using Visual.NET By Kevin Tse. Agenda What are Web Services and Why are they Useful ? SOAP vs CORBA Goals of the Web Service Project Proposed.
 Web pages originally static  Page is delivered exactly as stored on server  Same information displayed for all users, from all contexts  Dynamic.
Intro to Web Services Dr. John P. Abraham UTPA. What are Web Services? Applications execute across multiple computers on a network.  The machine on which.
.NET Mobile Application Development XML Web Services.
Overview of Previous Lesson(s) Over View  ASP is a technology that enables scripts in web pages to be executed by an Internet server.  ASP.NET is a.
Copyright © 2004, Keith D Swenson, All Rights Reserved. OASIS Asynchronous Service Access Protocol (ASAP) Tutorial Overview, OASIS ASAP TC May 4, 2004.
AJAX CS456 Fall Examples Where is AJAX used? Why do we care?
Submitted by: Moran Mishan. Instructed by: Osnat (Ossi) Mokryn, Dr.
JavaScript Invented 1995 Steve, Tony & Sharon. A Scripting Language (A scripting language is a lightweight programming language that supports the writing.
1 Seminar on SOA Seminar on Service Oriented Architecture BPEL Some notes selected from “Business Process Execution Language for Web Services” by Matjaz.
Servlets.
World Wide Web policy.
Web Programming Developing Web Applications including Servlets, and Web Services using NetBeans 6.5 with GlassFish.V3.
WEB SERVICES.
Working with Client-Side Scripting
Unit – 5 JAVA Web Services
Whether you decide to use hidden frames or XMLHttp, there are several things you'll need to consider when building an Ajax application. Expanding the role.
ASP.NET Module Subtitle.
An Introduction to JavaScript
Presentation transcript:

ASP.Net, web services--- asynchronous and synchronous and AJAX By Thakur Rashmi Singh

Presentation Flow  What is a webservice  Making a web service Call  What is synchronous call  What is asynchronous call  What is Ajax.  Conclusion.

Web Services?  “The W3C defines a Web service as a software system designed to support interoperable Machine to Machine interaction over a network”W3C What does that mean…  They allow programs written in different languages on different platforms to Communicate with each other in a standards- based way.  Provide an Service Oriented Architecture “SOA”.

Making Web Service Calls …  2 ways of adding the reference From cmd  by giving the command wsdl URL From the “Add Web Reference”.  Either methods a proxy class is generated.  When you choose the Add Web Reference option in Microsoft Visual Studio®.NET, Visual Studio.NET generates a proxy class.  Web Services are called through these proxy classes.

Proxy Class?  Generated by WSDL to describe what methods are available in the web service without showing the logic behind them.  proxy class takes care of the details of generating, transmitting and parsing the XML required to actually calling the remote Web service.

 The generated proxy class provides three methods for each Web service operation. One method named the same (used for synchronous calling) pair of methods prefixed with Begin and End to call the Web service asynchronously.

Ways of calling a Web Service  There are 2 ways of calling a web service Calling it synchronously Calling it Asynchronously.

Synchronous Calling…  Calling the Web service synchronously is a matter of creating an instance of the proxy and calling the method named the same as the Web service operation. Eg:

Performance……?  Web services are slow ! Reason?  latency involved when making calls across a network, especially over a relatively low- speed wireless connection.  Communicating large amounts of data may also cause the slowness. Result? Calling synchronously, the user interface of your application might freeze!!!

Solution???  The best way to make Web service calls is to make asynchronous Web service calls !

Asynchronous Calls…  When a synchronous call is made, the calling thread is blocked until the method completes whereas an asynchronous call is made on a different thread in a Thread pool, and this allows the original thread to continue its work while the asynchronous call is in progress.  Thread Pool? When a managed application is executed, the.NET runtime offers a pool of threads that will be created the first time the code accesses it. No overhead of creating and destroying separate threads for each task.

 Once the thread finishes it job we need to retrieve the results from the thread  Before retrieving the results of an Asynchronous Web service call, the application must first determine that the call has completed How do we know at what time the thread will complete the job?

Solution… Three ways to determine if the thread has finished its work or not.  Notification  Polling  Wait Handles

Notification  In this case, there is a function which can be called to notify once the thread completes it job. protected void Button1_Click(object sender, EventArgs e) { localhost.Service s = new localhost.Service(); s.BeginDelayedResponse(10000, Callback, s); } private void Callback(IAsyncResult result) { localhost.Service s = (localhost.Service)result.AsyncState; string re = s.EndDelayedResponse(result); Label2.Text = re; }  Only option which can exit the current working thread.

Polling  In some rare occasions, an application may wish to continue processing while periodically checking on the Web service call.

 If EndDelayedResponse is called before the request has completed, it will simply block until the request does complete.  But this method if not used carefully can end up using a lot of your machine's CPU cycles.

Wait Handles  Can be used when you need to make asynchronous calls, but you do not want to release the thread you are currently executing in.  It blocks the current thread till the web service completes.

 It can be WaitOne, WaitAll, WaitAny  WaitOne – wait for one webservice to complete  WaitAll – wait for all web services mentioned in the parameters array to complete  WaitAny – if any of the Web services mentioned in the parameters array completes then continue.  All can have timeout as a parameter.

AJAX  AJAX has many acronyms. The most common one is Asynchronous Java and XML.  It is a web techinque of making Asynchronous web requests.

Calling Web Services using AJAX  ASP.NET 2.0 AJAX Extensions enable the exact same experience of seamless proxy generation for Web services for client-side JavaScript that will run in the browser  You can invoke methods of the service from JavaScript by adding a ServiceReference

 You can now write your Javascript and call your webservice function OnLookup() { var stb = document.getElementById("_symbolTextBox"); StockQuoteService.GetStockQuote( stb.value, OnLookupComplete, OnError); } Where OnLookupComplete is another function which will be called after the webservice has completed OnError – is a function which is called during exceptions.

 Proxy is created in the client side by injecting a tag.  This proxy is invoked whenever a web service is requested.  This way of client side proxy generation and server side javscript support can be used intuitively to make asyn web calls.

If So easy then why not always use AJAX???

NoOoO….  Although it looks simple enough AJAX has one main concern…  The above technique won't work for external web services.  ASP.NET AJAX internally relies on the XML HTTP object  The XML HTTP object, for security reasons cannot communicate outside the originating web site. So no External Web Services…

 Although no direct solution for this has been found.  But a “bridge” technique can be used instead. Add a web reference to the external web service in your web site. Create a new web service in your web site. In the newly created web service, provide wrapper web methods that call the external web methods via web reference. Call this newly added web service from the client application

Interesting feature of ASP.NET AJAX  AJAX Extensions provide two pre-built services ProfileService AuthenicationService  With these two client-side proxy classes you can set and retrieve profile values for individual clients, as well as perform authentication (via the default Membership provider) and grant authentication cookies completely within client script.

Conclusion  Whenever executing a lengthy process where performance is an issue, Asynchronous calls are much better.  Also AJAX’s flashy looks and responsive UI and the ability to create client side proxies and using wrappers to call external web servies surely have the most compelling features so far.

References  ice_Calls#Page4 ice_Calls#Page4  meASPNET/default.aspx meASPNET/default.aspx  _ _4  c_webservices.html c_webservices.html  / / 

QUESTIONS???