400 likes | 1.14k Views
Introduction to Web Application. Introduction to Web Services. Topics. Service Oriented Architecture Web Services Architectures and Service-Oriented Architecture Roles in a Web Services Architecture Publish Services SOAP Demo a simple Web Service. Service-Oriented Architecture.
E N D
Introduction to Web Application Introduction to Web Services
Topics • Service Oriented Architecture • Web Services Architectures and Service-Oriented Architecture • Roles in a Web Services Architecture • Publish Services • SOAP • Demo a simple Web Service
Service-Oriented Architecture Service Registry Publish WSDL UDDI Find WSDL UDDI Bind SOAP WSDL Service Provider Service Requester
UDDI SOAP SOAP IIS SOAP Web Service Any Client Web Services As an Implementation of a Service-Oriented Architecture
CASE: An Electronic Funds Transfer Web Service Contoso MicropaymentWeb Service Woodgrove Bank Web Service Firewall Firewall Internet Firewall Northwind Electronic Funds Transfer Web Service Web Service Consumer
Roles in a Web Services Architecture • The Web Service Provider • The Web Service Requester • The Web Service Registry
The Web Service Provider • Web servers • The .NET Common Language Runtime • Examples of Web service providers
The Web Service Requester • Minimum functionality • Service location • Proxies • Asynchronous calls • Examples of Web service consumers
The Web Service Registry • Interactions between brokers and providers • Interactions between brokers and requesters • UDDI registries
Web service developer builds and deploys a pricing Web service 1 5 1 Web service developer registers and categorizes the Web service 2 Pricing Web Service 3 Web service consumer queries UDDI for “pricing” services 3 UDDI Services 2 Web service consumer determines the most appropriate “pricing” service 4 Web service developer builds a solution that directly consumes the Web service data 5 Overview of Using UDDI 4
SOAP Fundamentals • Overview of SOAP • Structure of SOAP Messages
Overview of SOAP • SOAP messages • Parts of a SOAP message • SOAP envelope • SOAP encoding rules • SOAP RPC representation • Protocol bindings for HTTP and HTTP-EF
Structure of SOAP Messages <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi=“…" xmlns:xsd=“…" xmlns:soap="http://schemas.xmlsoap.or g/soap/envelope/"> <soap:Head> <WoodgroveAuthInfo xmlns=“…"> <Username>string</Username> <Password>string</Password> </WoodgroveAuthInfo> </soap:Head> <soap:Body> <ToCelsius xmlns="http://tempuri.org/"> <TF>double</TF> </ToCelsius> </soap:Body> </soap:Envelope> • SOAP Envelope • SOAP Header • SOAP Body • SOAP Fault <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/”> <soap:Body> <soap:Fault> <faultcode>123XYZ</faultcode> <faultstring>Server Error</faultstring> <detail> … </detail> </soap:Fault> </soap:Body> </soap:Envelope>
Create A simple Web Service • TemperatureService [WebMethod] publicdouble ToCelsius(double TF) { Count++; return (5.0/9)*(TF-32); }
Using Proxy to invoke Web Services Web Service Web Service Consumer • Proxies and WSDL • Generating Proxies Using Wsdl.exe • Configuring Proxies
Generating Proxies Using Wsdl.exe wsdl [options] {URL | Path} • Syntax for invoking Wsdl.exe • Proxy class details Example wsdl http://localhost/class15/TemperatureService.asmx?wsdl Example wsdl /l:cs /protocol:HttpPost /out:Bank.cs http://localhost/class15/TemperatureService.asmx?wsdl
Configuring Proxies • Proxy property • AllowAutoRedirect property • Url property • Credentials property • Timeout property Bank theBank = new Bank(); theBank.Url = "http://eastcoast.woodgrovebank.com/Bank.asmx"; ICredentials credentials = new NetworkCredential ("Adam", "ABarr-user", "woodgrovebank.com"); theBank.Credentials = credentials; theBank.Timeout = 20000; IWebProxy proxyObject = new WebProxy("http://proxyserver:80", true); theBank.Proxy = proxyObject; theBank.AllowAutoRedirect = true;
Web Forms Client Web Service Consumer Demonstration: Implementing a Web Forms Client • Create an ASP.NET Web application • Add a Web reference • Invoke the Web service by using the proxy
Review • Service Oriented Architecture • Web Services Architectures and Service-Oriented Architecture • Roles in a Web Services Architecture • Publish Services • SOAP • Demo a simple Web Service