1 Web Services Visual C# 2008 Step by Step Chapter 30.

Slides:



Advertisements
Similar presentations
Session 6 Module 2 Calling a Web Service from an ASP.NET Web Page.
Advertisements

Intesar G Ali IT DepartmentPalestinian Land Authority Web services Prepared by: Intesar Ali IT Department PLA August 2010.
RPC Robert Grimm New York University Remote Procedure Calls.
11 Getting Started with ASP.NET Beginning ASP.NET 4.0 in C# 2010 Chapters 5 and 6.
1 Web Services I: Returning Data in XML Format. 2 Service-Oriented Architecture (SOA) Old Model for Applications Executables running on individual computers.
ASP.Net, web services--- asynchronous and synchronous and AJAX By Thakur Rashmi Singh.
Windows Communication Foundation and Web Services.
6/11/2015Page 1 Web Services-based Distributed System B. Ramamurthy.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 42 Web Services.
Remote Method Invocation Chin-Chih Chang. Java Remote Object Invocation In Java, the object is serialized before being passed as a parameter to an RMI.
XML Web Services ASP.NET. Overview of Web Services (Page 1) Web Service – Part or all of a Web application that is publicly exposed so that other applications.
Copyright © 2012 Pearson Education, Inc. Chapter 2 Introduction to Visual C#
Creating web service (and client application) with Visual Studio 2008 Create web service project New project->web->ASP.NET web service application (with.
Web Services February 14 th, Outline Overview of web services Create a web service with MS.Net Requirements for project Phase II.
Introduction SOAP History Technical Architecture SOAP in Industry Summary References.
ASP.Net, Web Forms and Web Controls 1 Outline Introduction Simple HTTP Transaction System Architecture Creating and Running a Simple Web Form Example Web.
Tutorial: Introduction to ASP.NET Internet Technologies and Web Application 4 th February 2010.
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
A Scalable Application Architecture for composing News Portals on the Internet Serpil TOK, Zeki BAYRAM. Eastern MediterraneanUniversity Famagusta Famagusta.
JavaScript & jQuery the missing manual Chapter 11
ASP.NET The.NET Framework. The.NET Framework is Microsoft’s distributed run-time environment for creating, deploying, and using applications over the.
Intro to C# Dr. John P. Abraham UTPA. Background required Thorough C++ programming – If you made an A in 1370/1170 you will do fine with some effort.
C Copyright © 2009, Oracle. All rights reserved. Appendix C: Service-Oriented Architectures.
CIS 375—Web App Dev II Microsoft’s.NET. 2 Introduction to.NET Steve Ballmer (January 2000): Steve Ballmer "Delivering an Internet-based platform of Next.
1 HRS2422 Web Services JAX-WS and SOAP Introduction  Web service – A software component stored on one computer that can be accessed via method.
Web Services Week 2 Aims: Getting started with creating simple C# applications within Visual Studio.NET Objectives: –An introduction to the syntax of C#.NET.
Distributed Communication via ASP.Net Web Services and.Net Remoting By Richard King.
CSCI 6962: Server-side Design and Programming Web Services.
James Holladay, Mario Sweeney, Vu Tran. Web Services Presentation Web Services Theory James Holladay Tools – Visual Studio Vu Tran Tools – Net Beans Mario.
Session 08: Architecture Controllers or Managers Graphical User Interface (GUI) FEN AK - IT Softwarekonstruktion.
CS 390- Unix Programming Environment CS 390 Unix Programming Environment Topics to be covered: Distributed Computing Fundamentals.
1 Working with Menus and Dialog Boxes. 2 Objectives You will be able to Create and edit menus for Windows Forms applications. Write code to handle menu.
Lecture 15 Introduction to Web Services Web Service Applications.
Web Services Week 7 Aims: A detailed look at the underlying mechanisms for communication between web services Objectives: SOAP, WSDL, UDDI.
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.
1 Data Bound Controls II Chapter Objectives You will be able to Use a Data Source control to get data from a SQL database and make it available.
Internet Technologies and Web Application Web Services With ASP.NET Tutorial: Introduction to.
.Net and Web Services Security CS795. Web Services A web application Does not have a user interface (as a traditional web application); instead, it exposes.
1 Chapter Eleven Handling Events. 2 Objectives Learn about delegates How to create composed delegates How to handle events How to use the built-in EventHandler.
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.
Establishing a foundation for web services Ashraf Memon.
1 Web Services Web and Database Management System.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Bookstore Application: Middle Tier Introducing Code-Behind Files, Session State.
1 CS 3870/CS 5870: Note 20 Web Service. 2 What is Web Service? Providing functionality online to other applications, Web and Windows applications. The.
ASP.NET Web Services.  A unit of managed code installed under IIS that can be remotely invoked using HTTP.
Week Six : Writing Web Services Aims: Creating and Consuming student’s first Web Services Learning Outcomes: Familiarity with VS.NET for creating and consuming.
Module 9: Using XML Web Services in a C# Application.
Chapter 7: Creating and Consuming XML Web Services Understanding XML Web Services Creating XML Web Services Deploying and Discovering XML Web Services.
Understanding Web Applications Lesson 4. Objective Domain Matrix Skills/ConceptsMTA Exam Objectives Understanding Web Page Development Understand Web.
Web Services from 10,000 feet Part I Tom Perkins NTPCUG CertSIG XML Web Services.
Web Services An Introduction Copyright © Curt Hill.
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.
11 User Controls Beginning ASP.NET in C# and VB Chapter 8.
Net-centric Computing Web Services. Lecture Outline  What is Web Service  Web Service Architecture  Creating and using Java Web Services  Apache Axis.
SOAP, Web Service, WSDL Week 14 Web site:
OE-NIK HP Advanced Programming Web services Standards and protocols Using web services Using web services with asynchronous calls.
Introduction to Web Services Srinath Vasireddy Support Professional Developer Support Microsoft Corporation.
11 jQuery Web Service Client. 22 Objectives You will be able to Use JSON (JavaScript Object Notation) for communcations between browser and server methods.
111 State Management Beginning ASP.NET in C# and VB Chapter 4 Pages
1 Adding a Model. We have created an MVC web app project Added a controller class. Added a view class. Next we will add some classes for managing movies.
Windows Communication Foundation and Web Services
Jim Fawcett CSE681 – SW Modeling & Analysis Spring 2005
Web Programming Developing Web Applications including Servlets, and Web Services using NetBeans 6.5 with GlassFish.V3.
How to Create a Simple Web Service and Use it in ASP.Net
Consuming Webservice in AX 2012
Serpil TOK, Zeki BAYRAM. Eastern MediterraneanUniversity Famagusta
Distributed System using Web Services
Chapter 42 Web Services.
Distributed System using Web Services
Presentation transcript:

1 Web Services Visual C# 2008 Step by Step Chapter 30

2 Objectives You will be able to Say what a web service is. Describe the interaction between a web service and a client program. Write a client program for a simple web service.

3 What are Web Services? Make web apps available to programs Like they are available to human users via web browsers. Use HTTP SOAP XML Motivation: Platform independence Drawback High communication overhead

4 Web Service Frameworks Version 3.5 of the.NET Framework provides two quite different ways to develop web services: ASP.NET Web Services The traditional approach Windows Communications Foundation New in.NET 3.5 and Visual Studio 2008 Covered in our textbook Visual Studio 2008 supports both methods. We will follow the traditional approach.

5 What is a.NET Web Service? Web Services in the.NET environment A form of remote method invocation (RMI) Layered on top of basic message based web service protocol. Motivation: Method invocation is familiar to programmers. No need to understand the SOAP protocol. No need to work directly with messages. This is the only form of web service that we will study.

6 How do RMI Web Services Work? Client code invokes “proxy” method on own system. Same interface as the remote method Proxy prepares a SOAP message encoding identification of function and arguments. Proxy sends message to web server on remote system. Web server on remote system parses the SOAP message and invokes the specified method. Web server sends result back as a SOAP message. Proxy on client system parses message and delivers result.

7 How do web services work? When using ASP.NET and Visual Studio Libarary functions handle most of the work. It is not necessary to understand the SOAP protocol or XML in order to use a web service. Let’s try a simple example: Greeting Service A web service method that returns the message “Hello, ” whenever it is invoked with a client’s name as the parameter value..

8 The Web Service Download from the class web site: Downloads/2011_04_19_Web_Services/ File Greeting_Service.zip Downloads/2011_04_19_Web_Services/ Expand the file. In Visual Studio File > Open Web Site Select Greeting_Service (Second level down) Click “Open” Examine the code Greeting_Service.cs

9 using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Services; [WebService(Namespace = " [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. // [System.Web.Script.Services.ScriptService] public class Greeting_Service : System.Web.Services.WebService { public Greeting_Service () { //Uncomment the following line if using designed components //InitializeComponent(); } [WebMethod] public string Say_Hello(string name) { return "Hello, " + name; }

10 Testing the Service How do we test the service? It needs a client! Internet Explorer provides a client that we can use to test a web service running under Visual Studio. Right click on Greeting_Service.asmx in the Solution Explorer window. Select View in Browser.

11 Testing the Service

12 Testing the Service Click here

13 Testing the Service Click here

14 Here is the Result Click the first tab to return, then click the “Back” button.

15 Service Description Click here

16 Service Description - WSDL End of Section

17 WSDL Web Services Description Language A web service must be able to provide a detailed specification of its interface upon request. Permits the client to construct a SOAP message in the correct format for this service. Visual Studio handles this transparently when we use it to write client software.

18 Consuming a Web Service Now let’s write a program to use the Greeting Service. Leave the web service running. We will need a proxy Presents same appearance to the client program as the remote method Communicates with the web server using SOAP messages. Passes result to client program as if the method had been executed locally.

19 Consuming a Web Service Start up another instance of Visual Studio First instance must continue running to support the service. Create a new C# Windows Forms Application project. Project. Not web site! Call it Test_Greeting_Service

20 Creating a Client Program

21 Design the Form btnSayHello tbResult tbName

22 Add Reference to the Web Service Adding a reference to the web service generates code for a class that will be the local proxy for the remote service. Provides the same interface that the web service defines at the remote site. Name of the proxy class will be the same as the name of the class that provides the web service. Project > Add Service Reference

23 Add Service Reference

24 Add Service Reference Click here

25 Make it a Web Reference Click here

26 Adding a Web Reference Paste in URL for the web service. (Or type it.) Then click Go. Browsing won’t work when the service is running in Visual Studio’s built in web server.

27 Adding a Web Reference

28 Adding a Web Reference Fill in Web a reference name. Than click “Add Reference”.

29 Check the Solution Explorer

30 What Functions Does the Service Provide?

31 Functions That We Can Call

32 Recall the Service Definition The class that provides the Say_Hello remote method was called “Greeting_Service”. Say_Hello is a method of class “Greeting_Service”.

33 Recall the Service Definition The proxy, generated by Visual Studio when we added the web reference, makes a functionally identical class available in the client program. Looks and acts as if the web service were local to the client program.

34 Include the Web Reference in "Usings" Open the code window for Form1.cs At the top, add: using Test_Greeting_Service.Greeting_Service_on_localhost; Namespace of this application The web reference that we added to the application

35 Add an Event Handler Back in Design window Double click on the “Say Hello" button, to generate an event handler for it. Fill in code to instantiate the Greeting_Service class and invoke its Say_Hello() method.

36 Event Handler using System; using System.Windows.Forms; using Test_Greeting_Service.Greeting_Service_on_localhost; namespace Test_Greeting_Service { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void btnSayHello_Click(object sender, EventArgs e) { Greeting_Service gs = new Greeting_Service(); tbResult.Text = gs.Say_Hello(tbName.Text); } The proxy class generated when we added the web reference The specific method to invoke within the web service.

37 Try it! Build and run the project.

38 Here is our result.

39 Summary: Creating a Web Service Client Know the URL and Interface definition for the web service. Create a normal Windows Forms application. Add a web reference. Start with service reference. Click “Advanced”. Specify URL of the web service. This adds a proxy class to the project. Proxy class interface is identical to that of the web service. Add “using” statement for the web reference. Instantiate the web service class. Invoke methods of the web service as if it were a local class. End of Presentation