Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Web Services in the Microsoft .Net Framework

Similar presentations


Presentation on theme: "Introduction to Web Services in the Microsoft .Net Framework"— Presentation transcript:

1 Introduction to Web Services in the Microsoft .Net Framework

2 Contents Introduction to Web Services
Introduction to Web Services in the Microsoft .Net Framework A Web Services Example: Microsoft’s .NET My Services Creating a Web Service in Visual Studio .Net Consuming a Web Service in Visual Studio .Net

3 Introduction to Web Services

4 Defining Web Services A web service is a chunk of functionality that can be accessed using web technology Across an intranet or the Internet Usually: What’s accessed is a method in a language such as Java or Visual Basic.NET The web technology used is the Simple Object Access Protocol (SOAP) carried over HTTP Both the .NET and Java camps have endorsed web services

5 Key Web Services Technologies
Web Services Description Language (WSDL) An IDL for web services Simple Object Access Protocol (SOAP) An XML-based protocol for web services Universal Description, Discovery, and Integration (UDDI) A directory service for web services

6 Illustrating Web Services Technologies
SOAP UDDI Registry Internet UDDI Registry Application Application Application WSDL Interface

7 Applying Web Services (1)
Connecting clients to Internet applications One example is Microsoft’s .NET My Services B2B integration on the Internet The next generation of EDI Enterprise application integration (EAI) on intranets A standard approach to connecting all applications

8 Applying Web Services (2)
Reservations Application Internet Airline Reservation System Intranet Seat Availability Application Pricing Application

9 Describing Web Services: WSDL
Created by Microsoft and IBM Recently handed to the World Wide Web Consortium (W3C) Endorsed by everybody: Microsoft, IBM, Sun, Oracle, BEA, more

10 Accessing Web Services: SOAP
The Simple Object Access Protocol (SOAP) allows invoking operations SOAP defines an XML-based format for parameters SOAP requests/responses can ride on: HTTP The most common case today SMTP or MSMQ For loosely-coupled interactions Other protocols

11 What SOAP Provides Industry agreement Object model independence
It’s endorsed by Microsoft, IBM, Sun, Oracle, BEA, Iona, and others Object model independence SOAP isn’t tied to any operating system, programming language, or object model Support for diverse protocols Synchronous and asynchronous

12 Illustrating A SOAP Message
Envelope Headers Body Method Parameters

13 An Example SOAP Request (1)
POST /AccountAccess HTTP/1.1 Host: Content-Type: text/xml; charset=“utf-8” Content-Length: 305 SOAPAction: <SOAP-ENV:Envelope xmlns:SOAP-ENV = " SOAP-ENV:encodingStyle = "

14 An Example SOAP Request (2)
<SOAP-ENV:Body> <m:GetBalance xmlns:m=" <Account> </Account> </m:GetBalance> </SOAP-ENV:Body > </SOAP-ENV:Envelope>

15 An Example SOAP Response (1)
HTTP/ OK Content-Type: text/xml; charset="utf-8" Content-Length: 304 <SOAP-ENV:Envelope xmlns:SOAP-ENV = " SOAP-ENV:encodingStyle = "

16 An Example SOAP Response (2)
<SOAP-ENV:Body> <m:GetBalanceResponse xmlns:m=" <Balance>3,822.55</Balance> </m:GetBalanceResponse> </SOAP-ENV:Body > </SOAP-ENV:Envelope>

17 Discovering Web Services: UDDI
Universal Description, Discovery, and Integration (UDDI) provides a specialized directory service for discovering compatible web services It uses XML It’s endorsed by Microsoft, IBM, Ariba, Oracle, Sun, BEA, and more An organization can create an XML-defined business registration Which can contain information about various available web services

18 Illustrating A UDDI Business Registration
Name: QwickBank Description: Internet Bank Contacts: Business Entity Business Service Name : Account access Binding Template: URL 1, tModel x Binding Template: URL 2, tModel y

19 The Trouble With UDDI (2000)
It’s complicated Microsoft’s .NET Framework ships a simpler discovery mechanism called Disco for use on intranets It’s not being used for web services yet Many businesses are registered, but not many WSDL definitions Without WSDL, developers can’t build interoperable web services clients

20 Introduction to Web Services in the Microsoft .Net Framework

21 ASP.NET The next generation of ASP (Active Server Pages)
It looks similar, but it’s actually very different Allows creating two kinds of applications: Browser applications Rely on .aspx pages Web services applications Rely on .asmx pages

22 Illustrating a Web Services Application
IIS class X { [WebMethod] public int Method1() { … } } SOAP app.asmx ADO.NET Common Language Runtime DBMS

23 Exposing Web Services: An Example .asmx Page (1)
WebService Language="c#" Class="Compute" %> using System.Web.Services; public class Compute { [WebMethod] public int Factorial(int f) int i; int result = 1; for (i=2; i<=f; i++) result = result * i; return result; }

24 Exposing Web Services: An Example .asmx Page (2)
[WebMethod] public double SquareRoot(double s) { return System.Math.Sqrt(s); }

25 XML Web Services Protocol Stack
Internet Protocols Directory of services: UDDI Service discovery: DISCO Microsoft specific ? Service descriptions: WSDL Service interactions: SOAP Universal type system: XSD Universal data format: XML Ubiquitous communication: Internet

26 The .NET Framework provides a bi-directional mapping
Web Services The .NET Framework provides a bi-directional mapping Application Concepts Web XML XSD WSDL SOAP Framework Objects Classes Methods Calls Data Schema Services Invocation

27 Web Services with .NET public class OrderProcessor
{ public void SubmitOrder(PurchaseOrder order) {...} } public class PurchaseOrder public string ShipTo; public string BillTo; public string Comment; public Item[] Items; public DateTime OrderDate; public class OrderProcessor { [WebMethod] public void SubmitOrder(PurchaseOrder order) {...} } [XmlRoot("Order", Namespace="urn:acme.b2b-schema.v1")] public class PurchaseOrder [XmlElement("shipTo")] public string ShipTo; [XmlElement("billTo")] public string BillTo; [XmlElement("comment")] public string Comment; [XmlElement("items")] public Item[] Items; [XmlAttribute("date")] public DateTime OrderDate; <?xml version="1.0" encoding="utf-8"?> <soap:Envelope> <soap:Body> <SubmitOrder> <Order date=" "> <shipTo>Manuel Costa</shipTo> <billTo>Bill Gates</billTo> <comment>Overnight delivery</comment> <items> <productId> </productId> <description>Dom Perignon</description> </items> </Order> </SubmitOrder> </soap:Body> </soap:Envelope> Order order = new Order(); order.ShipTo = "Manuel Costa"; order.BillTo = "Bill Gates"; order.OrderDate = DateTime.Today; OrderProcessor.SubmitOrder(order);

28 A Web Services Example: Microsoft’s .NET My Services

29 A Web Services Example: Microsoft’s .NET My Services
.NET My Services is a set of Internet-accessible web services that store data about users The data is described using XML Applications can access that data Access is via SOAP Users control which applications are allowed to access which parts of their data

30 Illustrating .NET My Services
Applications Clients Internet

31 Describing .NET My Services
Passport Based on Kerberos .NET Alerts .NET Services .NET Contacts .NET Locations .NET Calendar More

32 A .NET My Services Request
SOAP request: - Service name - PUID - Kerberos ticket - Method(Parameters) .NET My Services Applications .NET My Services SOAP response

33 .NET Services (Mark) .NET Contacts (Mark) Passport Service
5) Locate Mark’s .NET Contacts service .NET Services (Mark) 6) Look up Bob’s contact information and get his PUID .NET Contacts (Mark) 4) Get tickets for .NET My Services services 7) Locate Bob’s myNotifications service Passport Service .NET Services (Bob) Booking Application 1) Log in as Mark 2) Get ticket for application 8) Send notification to Bob 3) Request seats and invite Bob .NET Alerts (Bob) 9) Deliver notification to Bob .NET Locations (Bob)

34 Creating a Web Service in Visual Studio .Net

35 Creating a ASP.NET Web Service Project

36 Changing the Web Service Name

37 Accessing the Code Behind

38 Understanding the Code Behind
inheritance is optional (useful to create state full web services)

39 Editing the Code Behind
attribute that tells that this method should be exposed as a web service method

40 Understanding the .asmx page
In this case, everything is in the code behind

41 Build

42 Files Generated

43 Testing with a Browser

44 Viewing the dynamically generated WSDL (1)

45 Viewing the dynamically generated WSDL (2)

46 Consuming a Web Service in Visual Studio .Net

47 Creating a ASP. NET Web Application

48 Adding a Reference to the Web Service

49 Viewing the Proxy Class Created Behind the Scenes

50 Designing the web page

51 Calling the web service

52 Running the client application

53 Sources Seminário "Understanding .Net", David Chappell, FEUP, 2000
Seminário "Introduction to .NET", Manuel Costa, FEUP, 2001


Download ppt "Introduction to Web Services in the Microsoft .Net Framework"

Similar presentations


Ads by Google