1 / 21

Building and Using Web Services with ASP.NET

Building and Using Web Services with ASP.NET. Rob Howard Program Manager .NET Framework Team Microsoft Corp. Agenda. Overview Standards Based Building Web Services Using Web Services Beyond the Basics Web Service Security Summary. What is a Web Service?.

palti
Download Presentation

Building and Using Web Services with ASP.NET

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Building and Using Web Services with ASP.NET Rob HowardProgram Manager.NET Framework TeamMicrosoft Corp.

  2. Agenda • Overview • Standards Based • Building Web Services • Using Web Services • Beyond the Basics • Web Service Security • Summary

  3. What is a Web Service? • Browser is the most common tool for accessing information on the Internet • Web browser is not enough… • Devices, etc. • A web service is programmable application logic accessible via standard Web protocols • Programmable… • Available to a variety of clients (platform independent) • Standard protocols… • Network level interoperability

  4. Common Questions/Issues • How do you publish the location of a web service? • How do you describe a web service? • What protocols does it support? • What data types does it use? • Challenges • Programming model • Understanding of protocols, serialization, discovery, etc. • Solutions today still have complexities: • Microsoft SOAP Toolkit • IBM (SOAP Toolkit)

  5. Standards Based • SOAP (Simple Object Access Protocol) • Explicit serialization (HTTP + XML description) protocol used in service exchanges • WSDL (Web Service Description Language) • XML document describing the location and interfaces a particular service supports – the client's contract • DISCO (Discovery) • XML document describing (URI) of service • UDDI (Universal Description Discovery and Integration) • Yellow pages directory for services

  6. Discovery Find a Service http://www.uddi.org http://yourservice.com HTML or XML with link to WSDL Link to DISCO or WSDL document How do we talk? (WSDL) Web Service Consumer Web Service UDDI http://yourservice.com/?WSDL XML with service descriptions Let me talk to you (SOAP) http://yourservice.com/svc1 XML/SOAP BODY Web Services (In Practice) Design-Time or Dynamic Runtime

  7. ASP.NET Web Services • Goal: Make building web services easy • Compiled on first request or pre-compiled • First class feature of ASP.NET • File extension is .asmx • Write application logic • Use features of .NET to enable SOAP • We’re doing the interop work…

  8. ASP.NET Web Services • Part of the ASP.NET application model • Web Service is represented by an URL • Access to common objects: Request, Session, Application, etc. • The web service emits no UI • SOAP is for applications • However…. • Supports multiple protocols • Including SOAP • Extensible…

  9. Demo: Simple and Complex • Demo 1 – Writing a simple service • Add • Demo 2 – Comparing VB and C# • Fibonacci • Demo 3 – Writing a more complex service • Data Access

  10. .asmx Deconstructed 3 Mandatory additions, 1 optional addition • <%@ WebService class=“[class]" %> • Names the class and/or language used • Imports System.Web.Services • Required namespace • [WebMethod] or <WebMethod()> • Method is ‘web callable’ • WebService base class • Access ASP.NET intrinsic objects

  11. Protocols • Http-Get / Http-Post • Html forms name/value • SOAP (Simple Object Access Protocol) • Simple, lightweight XML protocol for exchanging structured and typed information on the Web • W3C note (May 8, 2000) • Supported by Microsoft, IBM, and others • Data is sent via POST (or M-POST) • Extensible XML document (Envelope, Encoding Rules, RPC)

  12. Using Web Services • Proxy characteristics • Classes are strongly typed • Supports both async and sync • Visual Studio.NET • Add Web Reference to a Project • WebServiceUtil.exe • Classes can be created in any .NET language • WSDL file from a given .NET class • Defined server .NET class from an WSDL

  13. Demo: Building Proxies • Demo 1 – Building a Proxy with VS.NET • Data Access • Demo 2 – Building a Proxy with Command line tool • Data Access

  14. Beyond the Basics • Soap Headers • Great way to send out of band data • Not part of the body • Similar to HTTP Headers • XML Attributes • Shape the XML to the format you need • XmlAttribute, XmlElement, XmlArray • SoapAttribute, SoapElement, SoapArray • Screen Scrape • Turn any HTML site into a web service*

  15. Demo: Beyond the Basics • Demo 1 – Working with SOAP Headers • Simple • Demo 2 – Shaping an XML document • Order Details • Demo 3 – Screen Scraping • Barnes and Noble

  16. Built-in Security Features • Data hiding (encryption): • Supports HTTPS • Use .NET Crypto classes ‘roll your own’ • Beta 1 does not support certificates • Authentication / Authorization • Supports Forms authentication • Supports Windows authentication • Supports ‘roll your own’

  17. Design Suggestions • Know and understand the supported data types • Don't send unnecessary data (such as an image) when you can send a URL • Eliminate latency in the server first • Use caching where possible • Build the service to be asynchronous if the potential exists to block other work

  18. Design Suggestions • Handle client errors when the server is unavailable • Cache data from the service where possible, rather than requesting the same data 100 times • Be efficient about the number of requests for dynamic data - collapse multiple web service methods into one • Read the SOAP, DISCO, and WSDL specs

  19. Summary • Building and using web services is .NET • Microsoft provides the leading platform for building web applications and services • Great support for XML, HTTP, HTML • Full extensibility enables developers to support the latest protocols • ASP.NET technology makes writing web services simple • Share application logic • Use existing skills and knowledge • Consistent development framework • Tool support is incredible!

  20. Resources • Microsoft ASP.NET Web Site • http://www.asp.net • Books • Wrox - “Preview of ASP+“ • Others definitely on the way • Additional Sites • http://msdn.microsoft.com/ • http://www.4guysfromrolla.com/ • http://www.asptoday.com • http://www.aspfree.com • http://www.aspng.com/

  21. Web Services Adopters

More Related