Presentation is loading. Please wait.

Presentation is loading. Please wait.

Web Services Overview.

Similar presentations


Presentation on theme: "Web Services Overview."— Presentation transcript:

1 Web Services Overview

2 Objectives Background Web Services Overview Microsoft® .NET Framework
Microsoft ASP.NET Web Services Overview Concepts and Architecture Design and Create Web Services Consume Web Services

3 Contents Section 1: Overview Section 2: Architecture
Microsoft .NET framework and ASP.NET Section 3: Creating Web Services Section 4: Using Web Services Invoking and consuming Web Services Section 5: Advanced Web Services State Management, Security, and Transactions Summary

4 Section 1: Overview “Looking Back ...“ What are Web Services?
Distributed Web applications

5 Looking Back ... Traditional distributed computing
Client/server model Distributed object model Components: packaging and interoperability Remoting: remote method invocation COM, CORBA, Java RMI and EJB Microsoft Windows DNA Distributed interNet Application Architecture DHTML, COM, ASP, Message Queuing The interactive Web

6 What’s Wrong with That? Distributed object models don‘t scale to the Internet Tightly coupling service and consumer Need for homogeneous infrastructure Versioning problems Limited COM support on non-Windows platforms CORBA is a remoting architecture CORBA Component Model Server object implementation not portable EJB—Enterprise JavaBeans The purely interactive Web

7 Web Services—Basics Expose services to other processes Black boxes
Internet or intranet Black boxes Component-like, reusable Based on the .NET Framework ASP.NET Web Services model Based on open standards HTTP, XML, and SOAP

8 Web Services—Basics Interconnect
Applications Different clients (M)any device Distribution and integration of application logic Web Services are loosely coupled Enable the programmable Web Not just the purely interactive Web

9 Distributed Web Applications
Devices, Browsers Vertical and portal service Access Application Call Services Internet Application App-specific Web Service Building block Web Service OS and local services Web Services Contract

10 Section 2: Architecture
The .NET Framework Architecture Programming Model Configuration

11 The .NET Framework Architecture
Microsoft .NET Framework System Services Common Language Runtime ASP.NET Web Forms Web Services Windows Forms Services Framework Base Data Debug ...

12 Programming model CIL & Metadata Source Code Compiler
Common Language Runtime Execution Engine Class Lib Class Loader JIT Compiler Managed native Code Execution

13 Configuration 1/2 Concepts and architecture Web.Config file
Hierarchical configuration architecture Influence on the actual directory and all subdirectories Root Dir Web.Config Sub Dir1 Sub Dir2

14 Configuration 2/2 Web.Config file WebServicesConfiguration class
XML based File is kept within the application directory Default and custom configuration Customized Web.Config file Customized configuration section handler WebServicesConfiguration class Contains configuration information <webServices> section in Web.Config

15 Section 3: Creating Web Services
Basics of Creating Web Services Web Services Infrastructure Code and Syntax Web Services Namespace Publishing Discovery

16 Creating Web Services—Basics
.asmx file Virtual path of ASP.NET Web application Stand-alone or part of an existing solution Web Services infrastructure Discovery, description, and wire format Microsoft Visual Studio.NET Microsoft Visual Basic.NET, C#, and Managed C++

17 Web Services Infrastructure
Client Discovery Request .vsdisco Return disco (XML) Web Service Description Request WSDL Return WSDL (XML) Protocol Request .asmx Return response (XML)

18 Code and Syntax WebService Directive WebMethod Attribute
Settings for ASP.NET compilers WebService Language=value Class=value %> WebMethod Attribute Code Declaration Syntax Outline Inline (in C#) WebService Class=“MyClass.MyWebService“ %> WebService Language=“C#“ Class=“MathService“ %> using System.Web.Services; public class MathService : WebService { [ WebMethod ] ...

19 Sample .asmx file WebService Language=“C#“ Class=“MathService“ %> using System; using System.Web.Services; public class MathService { [WebMethod] public int Subtract(int a, int b) { return a - b; } public int Subtract_vs(int a, int b) { return b - a; } }

20 System.Web.Services Namespace 1/2
Base class for Web Services Provides base functionality For example, WebService.Session WebServiceAttribute Optional class to add additional information WebMethodAttribute [ WebMethod ] Makes a method a Web Service method

21 System.Web.Services Namespace 2/2
WebServiceBindingAttribute Interface in WSDL Set of operations WebServicesConfiguration Contains configuration information <webservices> section in config.web WebServicesConfigurationSectionHandler

22 Publishing a Web Service
Expose Web Service and Web Service methods Create a Web Service proxy and an assembly Generate proxy with WSDL tool Create an assembly Enables developers to program against Web Services Publish WSDL contract and HTML description Web Service clients Can be Web applications or browsers

23 Discovery of Web Services
.vsdisco file XML-based file containing links to resources for retrieving WSDL Stored in the server‘s root directory Access via URL and dynamic discovery document Start discovering with the Disco tool Automatically created by Visual Studio.NET Global directory of Web Services through UDDI Universal Discovery, Description, and Integration (

24 Disco.exe Discovering Web Services Command-line example:
disco /out:location /domain:domain /username:username /password:password WebService1.vsdisco

25 WSDL.exe Web Services Description Tool Input: Output:
Create client proxy class Input: URL of a WSDL file, Proxy language, and protocol Username and password Output: Single source file in specified language, containing: Proxy class Code for network invocation and marshalling wsdl /l:C# /protocol:protocol /out:filename /namespace:MathServiceSpace MathService.sdl

26 Section 4: Using Web Services
Application Model Invoking Web Services Consuming Web Services Web Services Description Language (WSDL)

27 Web Application Developer
Application Model Web Service Developer Web Application Developer Web Server 1 Service App asmx .aspx Web Server 2 Service App Proxy Web Form

28 Invoking Web Services Web Services are URL addressable Protocols
HTTP request Protocols HTTP-GET Method name and arguments in URL HTTP-POST Method name and arguments in POST body HTTP-SOAP XML grammar for Addressing the Web Service Returning results

29 Invoking: HTTP-GET and HTTP-POST
Standard HTTP-GET Method name = PATHINFO Method arguments = URL query string Query string key = parameter name Multiple parameters Only primitive .NET runtime data types Result is an XML document Any .NET data type HTTP-POST Similar to GET, but with arguments in the form body

30 Invoking: HTTP-SOAP XML grammar for
Web Service method, method parameters, results Supports all standard .NET data types and value classes Additionally: classes, structs, datasets Class and struct marshalling Serialization in XML format

31 Consuming Web Services
Request without method name and parameters HTML description of Web Service Service capabilities, methods, protocols Web Service can return WSDL HTTP-GET, HTTP-POST, and HTTP-SOAP Request with parameter “?WSDL” Formal WSDL description of Web Service XML-based grammar Can be used as input for WebServiceUtil.exe

32 WSDL 1/2 XML grammar, defining:
Services and ports that communicate via messages Binding Specify a protocol or a data format for a message or a port Extensions for SOAP 1.1, HTTP GET/POST, and MIME Public description of a Web Service and its content WSDL contract Core Elements of WSDL service, port, and portType operations and messages

33 WSDL 2/2 An abstract illustration of WSDL elements service_1 port_C
message port_A port_D port type port_C port_B

34 Sample WSDL file <definitions name=“serviceName“> <import namespace=“ location=“ <portType name=“serviceNamePortType“> <operation name=“opName“> <input message=“msgNameInput“ /> <output message=“msgNameOutput“ /> </operation> </portType> <binding name=“serviceNameSoapBinding“> <soap:operation soapAction=“ /> </binding> <service name=“serviceName“> <port name=“serviceNamePort“ binding=“bindingName“> <soap:address location=" /> </port> </service> </definitions>

35 Section 5: Advanced Web Services
State Management Security Transactions Execution Model Distributed Web Applications

36 State Management Web Services are stateless
Use, for example, ASP.NET session state What is a session? Restricted to a logical application Context in which a user communicates to a server Functionality Request identification and classification Store data across multiple requests Session events Release of session data .NET State Server

37 Security Model Reasons for Security Security Configuration
Prevent access to areas of your Web server Record and store secure relevant user data Security Configuration Authentication, Authorization, Impersonation Code Access Security Walks the call stack to check authorization Web Client OS ASP.NET App IIS .NET

38 Transactions 1/2 Like ASP.NET Web Forms COM+ Services
COM+ automatic transactions Atomic, consistent, isolated, durable (ACID) SQL Server COM+ transaction context Application Web Service Message Queuing Server

39 Transactions 2/2 TransactionOption Property on WebMethod Attribute:
[WebMethod(TransactionOption= TransactionOption.Required)] Transaction Modes Disabled Supported NotSupported Required RequiresNew

40 Execution Model Synchronous Asynchronous
Like any other call to class methods Asynchronous .NET Framework design pattern Split the method into two code blocks BeginMethodName EndMethodName Client has to call Begin and End Pass a callback function or WaitHandle class

41 Using Web Services from UI
Completely separate layout and processing logic Two (or more) files: .aspx and .aspx.cs or .aspx.vb Files for designers and files for programmers Easy maintainability of your application .aspx .aspx.cs

42 Sample .aspx .asmx file implements method “Add”
WSDL file, returned by the ASP.NET runtime Import Namespace=“MathServiceSpace“ %> <script language=“C#“ runat="server"> public void Submit_Click(Object S, EventArgs E) { service.Add(operand1, operand2); </script> <input OnServerClick=“Submit_Click“ runat="server" ...>

43 Sample C# proxy class, generated by WSDL.exe
[System.Web.Services.Protocols. SoapDocumentMethodAttribute(“ public int Add(int a, int b) { object[] results = this.Invoke(“Add“, new object[] {a, b}); return (int)(results[0]); } public System.IAsyncResult BeginAdd(... public int EndAdd(...

44 Summary .NET Architecture Overview Web Services and ASP.NET
Create and Publish Web Services Invoke and Consume Web Services WSDL and Proxy Classes Program Against Web Services

45 Questions

46 ASP.NET QuickStart Tutorial
A Simple Web Service ASP.NET QuickStart Tutorial

47 ASP.NET QuickStart What Is It? Installation .NET Framework Samples
Tutorial, ASP.NET samples Syntax, architecture, features Installation Install Microsoft .NET Framework SDK Visual Studio.NET installation and Components Update Installation of Visual Studio.NET is not mandatory .NET Framework Samples ASP.NET QuickStart  ASP.NET Web Services  Writing a Simple Web Service

48 Building a Simple Web Service
Create your own MathService .asmx Implement class MathService and Web methods Create WSDL file (MathService.wsdl) Request to MathService.asmx Generate C# proxy class (MathService.cs) WebServiceUtil.exe Generate Assembly (MathService.dll) C# compiler “csc”

49 Consuming a Simple Web Service
Implement MathService client (MathServiceClient.aspx) ASP.NET UI Operands  Text box Methods  Buttons Result  Label Event Handler OnServerClick

50 TerraServer. Microsoft.net

51 Overview What is it? Assumptions for this tutorial Set of Web methods
Programmable interface to online database Aerial imagery and topographical maps Assumptions for this tutorial Visual Studio.NET Internet connection

52 Tutorial Create a new project Create application UI Add Web reference
Implement functionality

53 Legal Notices Unpublished work. Ó 2001 Microsoft Corporation. All rights reserved. Microsoft, Visual Basic, Visual Studio, and Windows are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries. The names of actual companies and products mentioned herein may be the trademarks of their respective owners.


Download ppt "Web Services Overview."

Similar presentations


Ads by Google