Introduction to Web Services in the Microsoft 'Net Framework

1 / 53
About This Presentation
Title:

Introduction to Web Services in the Microsoft 'Net Framework

Description:

Host: www.qwickbank.com. Content-Type: text/xml; charset='utf-8' Content-Length: 305 ... Creating a ASP. NET Web Application. 48. Web Services, LES, 2004/05 ... –

Number of Views:132
Avg rating:3.0/5.0
Slides: 54
Provided by: grad159
Category:

less

Transcript and Presenter's Notes

Title: Introduction to Web Services in the Microsoft 'Net Framework


1
Introduction to Web Servicesin the Microsoft
.Net Framework
2
Contents
  • Introduction to Web Services
  • Introduction to Web Services in the Microsoft
    .Net Framework
  • A Web Services Example Microsofts .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
  • Whats 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
UDDI Registry
Internet
UDDI Registry
Application
Application
Application
WSDL Interface
7
Applying Web Services (1)
  • Connecting clients to Internet applications
  • One example is Microsofts .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)
Internet
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
  • Its endorsed by Microsoft, IBM, Sun, Oracle,
    BEA, Iona, and others
  • Object model independence
  • SOAP isnt 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 www.qwickbank.com
  • Content-Type text/xml charsetutf-8
  • Content-Length 305
  • SOAPAction
  • ltSOAP-ENVEnvelope
  • xmlnsSOAP-ENV
  • "http//schemas.xmlsoap.org/soap/envelope/"
  • SOAP-ENVencodingStyle
  • "http//schemas.xmlsoap.org/soap/encoding/"gt

14
An Example SOAP Request (2)
  • ltSOAP-ENVBodygt
  • ltmGetBalance
  • xmlnsm"http//www.qwickbank.com/bank"gt
  • ltAccountgt729-1269-4785lt/Accountgt
  • lt/mGetBalancegt
  • lt/SOAP-ENVBody gt
  • lt/SOAP-ENVEnvelopegt

15
An Example SOAP Response (1)
  • HTTP/1.1 200 OK
  • Content-Type text/xml charset"utf-8"
  • Content-Length 304
  • ltSOAP-ENVEnvelope
  • xmlnsSOAP-ENV
  • "http//schemas.xmlsoap.org/soap/envelope/"
  • SOAP-ENVencodingStyle
  • "http//schemas.xmlsoap.org/soap/encoding/"gt

16
An Example SOAP Response (2)
  • ltSOAP-ENVBodygt
  • ltmGetBalanceResponse
  • xmlnsm"http//www.qwickbank.com/bank"gt
  • ltBalancegt3,822.55lt/Balancegt
  • lt/mGetBalanceResponsegt
  • lt/SOAP-ENVBody gt
  • lt/SOAP-ENVEnvelopegt

17
Discovering Web Services UDDI
  • Universal Description, Discovery, and Integration
    (UDDI) provides a specialized directory service
    for discovering compatible web services
  • It uses XML
  • Its 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
19
The Trouble With UDDI (2000)
  • Its complicated
  • Microsofts .NET Framework ships a simpler
    discovery mechanism called Disco for use on
    intranets
  • Its not being used for web services yet
  • Many businesses are registered, but not many WSDL
    definitions
  • Without WSDL, developers cant 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 its 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)
  • lt_at_ WebService Language"c" Class"Compute" gt
  • using System.Web.Services
  • public class Compute
  • WebMethod public int Factorial(int f)
  • int i
  • int result 1
  • for (i2 iltf 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
Web Services
Application Concepts
Data
Schema
Services
Invocation
27
Web Services with .NET
public class OrderProcessor WebMethod
public void SubmitOrder(PurchaseOrder order)
... XmlRoot("Order", Namespace"urnacme.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
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
lt?xml version"1.0" encoding"utf-8"?gt ltsoapEnvel
opegt ltsoapBodygt ltSubmitOrdergt ltOrder
date"20010703"gt ltshipTogtManuel
Costalt/shipTogt ltbillTogtBill
Gateslt/billTogt ltcommentgtOvernight
deliverylt/commentgt ltitemsgt
ltproductIdgt17748933lt/productIdgt
ltdescriptiongtDom Perignonlt/descriptiongt
lt/itemsgt lt/Ordergt lt/SubmitOrdergt
lt/soapBodygt lt/soapEnvelopegt
Order order new Order() order.ShipTo "Manuel
Costa" order.BillTo "Bill Gates" order.OrderDa
te DateTime.Today OrderProcessor.SubmitOrder(
order)
28
A Web Services Example Microsofts .NET My
Services
29
A Web Services Example Microsofts .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
.NET My Services
Internet
Clients
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
.NET Services (Bob)
Booking Application
.NET Alerts (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
Write a Comment
User Comments (0)
About PowerShow.com