Web Services with ASP.NET. Asst. Prof. Dr. Kanda Saikaew (krunapon@kku.ac.th) Department of Computer Engineering Khon Kaen University



Similar documents
Web Services in.net (1)

Walkthrough: Creating and Using an ASP.NET Web Service in Visual Web Developer

Creating and Consuming XML Web Services

Programming in C# with Microsoft Visual Studio 2010

Web services can convert your existing applications into web applications.

Ambientes de Desenvolvimento Avançados

Course 20532B: Developing Microsoft Azure Solutions

Demo: Controlling.NET Windows Forms from a Java Application. Version 7.3

Q Lately I've been hearing a lot about WS-Security. What is it, and how is it different from other security standards?

MS 10978A Introduction to Azure for Developers

Course 10978A Introduction to Azure for Developers

Developing Microsoft Azure Solutions 20532B; 5 Days, Instructor-led

Developing Microsoft Azure Solutions

CSCI 5828 Spring 2010 Foundations of Software Engineering. - Arpit Sud

C#5.0 IN A NUTSHELL. Joseph O'REILLY. Albahari and Ben Albahari. Fifth Edition. Tokyo. Sebastopol. Beijing. Cambridge. Koln.

Developing Microsoft Azure Solutions 20532A; 5 days

Dynamic Web Programming BUILDING WEB APPLICATIONS USING ASP.NET, AJAX AND JAVASCRIPT

Lab Introduction to Web Services

Developing a Web Server Platform with SAPI Support for AJAX RPC using JSON

Installing the ASP.NET VETtrak APIs onto IIS 5 or 6

Cache Configuration Reference

Creating Form Rendering ASP.NET Applications

Introduction to Azure for Developers

10978A: Introduction to Azure for Developers

How To Train Aspnet

Building and Using Web Services With JDeveloper 11g

Microsoft Introduction to Azure for Developers

QuadraMed Enterprise Scheduling Combined Service Installation Guide. Version 11.0


Whats the difference between WCF and Web Services?

Extending XSLT with Java and C#

ScanJour PDF 2014 R8. Configuration Guide

Chapter 1: General Introduction What is IIS (Internet Information Server)? IIS Manager: Default Website IIS Website & Application

Application Domains and Contexts and Threads, Oh My!

Census. di Monitoring Installation User s Guide

The Microsoft Way: COM, OLE/ActiveX, COM+ and.net CLR. Chapter 15

ASP &.NET. Microsoft's Solution for Dynamic Web Development. Mohammad Ali Choudhry Milad Armeen Husain Zeerapurwala Campbell Ma Seul Kee Yoon

Creating XML Report Web Services

A standards-based approach to application integration

ADOBE AIR. Working with Data in AIR. David Tucker

CHAPTER 10: WEB SERVICES

.NET Overview. David Smith. Today s s Topics. Why am I here? A tool. Microsoft s s Vision for.net

ActiveVOS Server Architecture. March 2009

Analytics Configuration Reference

Module 13 Implementing Java EE Web Services with JAX-WS

55014-Upgrading Your Development Skills to SharePoint 2013

Quartz.Net Scheduler in Depth

Performance Testing for Ajax Applications

Terms and Definitions for CMS Administrators, Architects, and Developers

Getting Started with the Internet Communications Engine

BUILDER 3.0 Installation Guide with Microsoft SQL Server 2005 Express Edition January 2008

Lab 8: ASP.NET 2.0 Configuration API and Health Monitoring

metaengine DataConnect For SharePoint 2007 Configuration Guide

Introducing Apache Pivot. Greg Brown, Todd Volkert 6/10/2010

OTP Server. Integration module. Nordic Edge AD Membership Provider for Microsoft ASP.NET. Version 1.0, rev. 6. Nordic Edge

This three-day instructor-led course provides students with the tools to extend Microsoft Dynamics CRM 4.0.

Configuring.NET based Applications in Internet Information Server to use Virtual Clocks from Time Machine

: provid.ir

CRM Setup Factory Installer V 3.0 Developers Guide

Application Architecture for.net: Designing Applications and Services

SharePoint 2013 Logical Architecture

Sage 100 ERP. ebusiness Web Services Installation and Reference Guide

Harnessing.NET as a Framework for Assessment Data Management

TIBCO Spotfire Platform IT Brief

DEVELOPMENT OF A WORKFLOW APPLICATION FOR VEHICLE FLEET MANAGEMENT: A CASE STUDY OF GUINNESS NIGERIA PLC

SQL Desktop Application For WebService in C# dr inż. Tomasz Tatoń

SAML v1.1 for.net Developer Guide

How to configure the DBxtra Report Web Service on IIS (Internet Information Server)

Dragan Juričić, PBZ May 2015

MEALS2SHARE Neighborhood Home Cooked Food Sharing Web Application

Microsoft Dynamics AX 2012 Implementation Planning Guide. Microsoft Corporation Published: August 2011

Developing Microsoft SharePoint Server 2013 Advanced Solutions. Version: Demo. Page <<1/8>>

Programming in C# with Microsoft Visual Studio 2010

Logi Ad Hoc Reporting Configuration for Load Balancing (Sticky Sessions)

SQL Server 2005: Web Services

Start Oracle Insurance Policy Administration. Activity Processing. Version

ACE 2011 International. Role Based Clients. aras.com

System Requirements for Microsoft Dynamics NAV 2016

About the Authors Fundamentals p. 1 Introduction to LDAP and Active Directory p. 3 A Brief History of Directory Services p. 3 Definition of LDAP p.

A Tool for Evaluation and Optimization of Web Application Performance

RoomWizard Synchronization Software Manual Installation Instructions

DotNet Web Developer Training Program

Password Reset Server Installation Guide Windows 8 / 8.1 Windows Server 2012 / R2

Proof of Concept. A New Data Validation Technique for Microsoft ASP.NET Web Applications. Foundstone Professional Services

Save Actions User Guide

Web Services Development using Top-down Design

Application Development,.NET

XIA Configuration Server

TIBCO Spotfire Statistics Services Installation and Administration Guide. Software Release 5.0 November 2012

Introducing the.net Framework 4.0

Objectif. Participant. Prérequis. Remarque. Programme. C# 3.0 Programming in the.net Framework. 1. Introduction to the.

Course MS10975A Introduction to Programming. Length: 5 Days

A Guide to Building Enterprise Applications on the.net Framework (Building Distribut...

How To Write A Distributed Deployment System On Nix (Programming)

Last edited on 7/30/07. Copyright Syncfusion., Inc

Click Studios. Passwordstate. Installation Instructions

Oracle WebLogic Server

Upgrading Your Development Skills to SharePoint 2013 Course 55014A; 5 Days, Instructor-led

System Requirements for Microsoft Dynamics NAV 2016

Course Name: ADVANCE COURSE IN SOFTWARE DEVELOPMENT (Specialization:.Net Technologies)

Transcription:

Web Services with ASP.NET Asst. Prof. Dr. Kanda Saikaew (krunapon@kku.ac.th) Department of Computer Engineering Khon Kaen University 1

Agenda Introduction to Programming Web Services in Managed Code Programming the Web with Web services Creating Web Services in Managed Code XML Web Services Created Using ASP.NET and XML Web Service Clients 2

What is ASP.NET? ASP.NET is a web application framework developed and marketed by Microsoft Allow programmers to build dynamic web sites, web applications and web services ASP.NET is built on the Common Language Runtime (CLR), allowing programmers to write ASP.NET code using any supported.net language 3

What is MS.NET Framework? It is a software framework that is available with several Microsoft Windows operating systems It includes a large library of pre-coded solutions to common programming problems and a virtual machine that manages the execution of programs written specifically for the framework The.NET Framework is a key Microsoft offering and is intended to be used by most new applications created for the Windows platform 4

ASP.NET Web Services Using the ASP.NET page framework, enabling these Web services to access the many features of the.net Framework Authentication, caching, and state management. ASP.NET and the.net Framework are the basis for Web services in managed code Developers can focus on creating or accessing Web services without needing to write infrastructure code. 5

ASP.NET Application Model Web pages intended for the browser use the.aspx extension Web services use the.asmx extension. There are two fundamental roles when working with Web services: Creating a Web service Accessing a Web service 6

Web Services Scenarios Web services can be either standalone applications or subcomponents of a larger Web application For example, suppose you are creating a Web application that sells books online How might your Web application interact with Web services? 7

Book sellers and Web Services (1/2) Creating Web service Your application exposes its order processing logic as a Web service Your affiliate Web sites can in turn use in their Web applications to sell books through your online store without requiring their customers to visit your site. 8

Book sellers and Web Services (2/2) Accessing Web service Your application accesses Web service provided by another online company that specializes in writing and supplying book reviews for online booksellers When a visitor to your online store views the details of a particular book, they also see the reviews of that book on the same page. 9

Agenda Introduction to Programming Web Services in Managed Code Programming the Web with Web services Creating Web Services in Managed Code XML Web Services Created Using ASP.NET and XML Web Service Clients 10

Building a Basic XML Web Service using ASP.NET (1/2) 1. Create a file with an.asmx file name extension and declare a Web service in it using an @WebService directive 2. Create a class that implements the Web service. The class can optionally derive from the WebService class 11

Building a Basic XML Web Service using ASP.NET (2/2) 3. Optionally, apply the WebService attribute to the class implementing the Web service 4. Define the Web service methods that compose the functionality of the Web service 12

Declaration of Web Services (1/2) When you create a Web service in ASP.NET, you place the required @ WebService directive at the top of a text file with an.asmx file name extension The presence of the.asmx file and the @ WebService directive correlate the URL address of the Web service with its implementation 13

Declaration of Web Services (2/2) By applying the optional WebService attribute to a class that implements a Web service You can set the default XML namespace for the Web service along with a string to describe the Web service It is highly recommended that this default namespace, which originally is http://tempuri.org, be changed before the Web service is made publicly consumable 14

Declaring a Web Service Example1 (1/2) To declare a Web service whose implementation resides in the same file Add an @WebService directive to the top of a file with an.asmx file name extension Specify the class that implements the Web service Specify the programming language that is used in the implementation 15

Declaring a Web Service Example1 (2/2) C# <%@ WebService Language= C# Class= Util %> Visual Basic <%@ WebService Language="VB" Class="Util" %> 16

Declaring a Web Service Example2 (1/2) To declare a Web service whose implementation resides in an assembly Add an @ WebService directive to the top of a file with an.asmx extension Specify the class that implements the Web service Specify the assembly that contains the implementation Specify the programming language that is used in the implementation 17

Declaring a Web Service Example2 (2/2) The following @ WebService directive is the only line in a file with an.asmx extension Specifying that the MyName.MyWebService class resides in the MyAssembly assembly within the \Bin directory <%@ WebService Language="C#" Class="MyName.MyWebService,MyAss embly" %> 18

Building a Basic XML Web Service using ASP.NET (1/2) 1. Create a file with an.asmx file name extension and declare a Web service in it using an @WebService directive 2. Create a class that implements the Web service. The class can optionally derive from the WebService class 19

Deriving from the WebService Class Classes that implement a Web service can optionally derive from the WebService class To gain access to the common ASP.NET objects, such as WebService.Application WebService.Session WebService.User WebService.Context 20

Sample Derivation from WebService Class <%@ WebService Language="C#" Class="Util" %> using System; using System.Web.Services; public class Util: WebService 21

Building a Basic XML Web Service using ASP.NET (2/2) 3. Optionally, apply the WebService attribute to the class implementing the Web service 4. Define the Web service methods that compose the functionality of the Web service 22

Applying the WebService Attribute Apply the optional WebService attribute to a class that implements a Web service to set The XML namespace for the Web service The description of Web service The default namespace originally is http://tempuri.org 23

Applying WebService Attribute <%@ WebService Language="C#" Class= "ServerVariables"%> using System; using System.Web.Services; [ WebService( Description= Calculator Service", Namespace="http://campus.en.kku.ac.th/")] public class Calculator: WebService { 24

Building a Basic XML Web Service using ASP.NET (2/2) 3. Optionally, apply the WebService attribute to the class implementing the Web service 4. Define the Web service methods that compose the functionality of the Web service 25

Definition of Web Service Methods Apply a WebMethod attribute to public methods in the class that implements a Web service Have the ability to receive Web service requests and send back responses The method and class must be public and running inside an ASP.NET Web application 26

Declaring a Web Service Method Add public methods to the class that is implementing the Web service. Apply the WebMethod attribute to the public methods that you want to be mapped to Web service operations 27

Declaring a Web Service Method Example <%@ WebService Language="C#" Class="Util" %> using System.Web.Services; using System; [WebService (Namespace="http://campus.en.kku.ac.th/")] public class Util: WebService { [ WebMethod] public long Multiply(int a, int b) { return a * b; } } 28

Asynchronous XML Web Service Methods To improve performance of Web service methods that invoke long-running methods that block their thread You should consider exposing them as asynchronous Web service methods Implementing an asynchronous Web service method allows that thread to execute other code when it is returned to the thread pool Allows one more of the limited number of threads to execute, enhancing the overall performance and scalability of the system 29

Implementing Asynchronous Web Service Method (1/3) 1) Split a synchronous Web service method into two methods Each with the same base name, one with that name starting with Begin and the other End // Define the Begin method. [WebMethod] public IAsyncResult BeginGetAuthorRoyalties(String Author, AsyncCallback callback, object asyncstate) { } // Define the End method. [WebMethod] public AuthorRoyalties EndGetAuthorRoyalties(IAsyncResult asyncresult) { } } 30

Implementing Asynchronous Web Service Method (2/3) 2) The parameter list for the Begin method contains all the in and by reference parameters for the method's functionality plus two additional parameters By reference parameters are listed as in parameters The second from the last parameter must be an AsyncCallback. The AsyncCallback parameter allows a client to supply a delegate, which is invoked when the method completes The last parameter is an Object. The Object parameter allows a caller to supply state information to the method The return value must be of type IAsyncResult. // Define the Begin method. [WebMethod] public IAsyncResult BeginGetAuthorRoyalties(String Author, AsyncCallback callback, object asyncstate) { } 31

Implementing Asynchronous Web Service Method (3/3) 3) The parameter list for the End method consists of an IAsyncResult followed by any out and by reference parameters specific to the method's functionality. The return value is the same type as the return value of a synchronous Web service method By reference parameters are listed as out parameters // Define the End method. [WebMethod] public AuthorRoyalties EndGetAuthorRoyalties(IAsyncResult asyncresult) { } 32

Accessing Web Services 1. Locate the Web service you want to access 2. Create a proxy class for the Web service by adding a Web reference to your project 3. Reference the proxy class in the client code by including its namespace 4. Create an instance of the Web service proxy class in the client code 5. Access the Web service using the methods of the proxy 33

Accessing Web Services Example Using System; namespace Applicaion1 { class Class1 { static void Main() { Converter.Service1 cservice = new Converter.Service1(); Console.WriteLine( Temperature I degrees Fahrenheit: ); double dfahrenheit = Convert. 34