1 / 19

Web Services

Learn about ASP.NET web services and their benefits for cross-platform and cross-business computing. Understand the standards like SOAP, WSDL, and UDDI that enable interoperability. Discover how to create and consume web services using SOAP.

cshepard
Download Presentation

Web Services

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. Web Services

  2. ASP.NET Web Services • Goals of ASP.NET Web services: • To enable cross-platform, cross-business computing • Great for “service” based operations that have few methods: Google searches, Amazon integration, etc. • ASP.NET Web services are “method-oriented”, not object-oriented • Everything is passed by value: no references to server objects

  3. ASP.NET Web Services • Usually uses SOAP over HTTP POST – platform independent messages • Hosted in IIS • Can use built-in authentication and encryption via IIS • Technically stateless, but can use regular ASP.NET Session variables • Very easy to use, with good support in Visual Studio.NET • Doesn’t support: • Events / callbacks • Object references

  4. Standards-Based • SOAP (Simple Object Access Protocol) • XML-based protocol for messaging • WSDL (Web Service Description Language) • Document describing the message exchange contract • DISCO (Discovery) • Simple protocol for publishing available services • UDDI (Universal Description Discovery and Integration) • Yellow pages directory for services

  5. SOAPSimple Object Access Protocol • XML based protocol to exchange structured and typed information • Remote Procedure Calls (RPC) • Serialization Rules (XSD) • Extensible

  6. WSDLWeb Service Definition Language • An XML-based grammar for describing the capabilities of Web Services • Extensible • Jointly developed by Microsoft and IBM • Similar in concept to IDL, but it’s not IDL • To parse WSDL you need XML parser

  7. UDDIUniversal Description, Discovery and Integration • A project to speed interoperability and adoption for web services • Standards-based specifications for service description and discovery • Shared operation of a business registry on the web • Partnership among industry and business leaders • Open process with clear roadmap to a standards body

  8. UDDI (XML Web Service Broker) XML Web Service Consumer XML Web Service Provider Overview of XML Web Service Architectures Find Publish Internet Bind

  9. Web Services As an Implementation of a Service-Oriented Architecture UDDI SOAP SOAP IIS Any Client SOAP .NET Web Service

  10. 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

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

  12. Simple Example <%@ WebService Language="C#" Class="HelloWorld" %> using System; using System.Web.Services; public class HelloWorld : WebService {   [WebMethod] public String SayHelloWorld() { return "Hello World"; } }

  13. SOAP • Simple Object Access Protocol • XML-based standard that defines how method calls can be made over HTTP, and how the server’s response should be formatted • You need to know it because • in certain circumstances where you might want to use SOAP to exchange special “meta” information along with each method call

  14. SOAP Elements • Envelope (mandatory) • Top element of the XML document representing the message • Header (optional) • Determines how a recipient of a SOAP message should process the message • Adds features to the SOAP message such as authentication, transaction management, message routes, etc… • Body (mandatory) • Exchanges information intended for the recipient of the message. • Typical use is for RPC calls and error reporting.

  15. POST /HelloWorld/Hello.asmx HTTP/1.1 Host: localhost Content-Type: text/xml; charset=utf-8 Content-Length: lengthSOAPAction: "http://tempuri.org/Add" <?xml version="1.0" encoding="utf-8"?> <soap:Envelope …> <soap:Header> <AuthHeader xmlns="http://tempuri.org/"> <Username>avi</Username> <Password>xM76w@</Password> </AuthHeader> </soap:Header> <soap:Body> <Add xmlns="http://tempuri.org/"> <a>23</a> <b>44</b> </Add> </soap:Body> </soap:Envelope>

  16. SOAP Fault • Used to carry error and/or status information within a SOAP message • Appears within the SOAP body • Defines the following: • faultcode (mandatory) • Faultstring (mandatory) • faultactor (optional) • Detail

  17. SOAP Fault Example <SOAP:Fault> <faultcode>SOAP:Server</faultcode> <faultstring>Internal Application Error</faultstring> <detail xmlns:f=“http://www.a.com/CalculatorFault”> <f:errorCode>794634</f:errorCode> <f:errorMsg>Divide by zero</f:errorMsg> </detail> </SOAP:Fault>

  18. Soap ExtensionsCreating • Create a class derived from SoapExtension • Create a class derived from SoapExtensionAttribute • Overload the constructor if necessary • Define any custom properties • Overload the ‘ExtensionType’ property to return the type of your derived SoapExtension class • Apply the attribute to a web method or web service class

  19. Soap ExtensionsUses • Used for More Advanced Functionality • Intercept Calls to a Web Service • Intercept Calls to a Web Method • Pre and Post Processing • Tracing • Encryption • Compression

More Related