html5-img
1 / 22

Web Services

Web Services. What is a web service? Why should I care – what can I do with it? How do I make one? How do I use one? The extended web services vision (Microsoft’s version of a widely shared vision for distributed computing services). What is a web service.

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 • What is a web service? • Why should I care – what can I do with it? • How do I make one? • How do I use one? • The extended web services vision (Microsoft’s version of a widely shared vision for distributed computing services)

  2. What is a web service • A web service is a .NET program (project) that functions like a subroutine to potential users anywhere on the web. • Not a complete web project – typically a computation or database look-up. (A good way to allow access to your database while isolating it from direct hacking.) • Accessed by a URL (web address of the machine on which it resides + its directory path)

  3. Web services in action (1) • A web service request is a well formed XML document which masquerades as HTML so it can freely pass through firewalls Web service request (as XML) Web service reply (as XML)

  4. Web services in action (2) • The receiving system (a web server) processes the request for service very much like a .aspx call. • The received request is routed to .NET web service handlers. • These handlers parse the XML and pass the parameters to the web service

  5. Web services in action (3) • The web service procedural code runs just as a function call would under .NET • The procedural code returns its result(s) to the .NET web service handler • The handler creates an XML message packet which is handed back to the HTTP (web) server. • The server puts the packet back on the web, addressed to the sender

  6. Web services in action (4) • When the message packet arrives back at the calling machine, web services handlers there parse the XML message and pass the requested data to the calling program just as if a local function had been called.

  7. Web services in action (5) Firewall XML encoding Web service procedural code .NET code XML decoding Web service request (as XML) WS call parameters data data Web service reply (as XML) XML decoding XML encoding .NET web service handlers

  8. Web Services: Why? (1) • Suppose you run a business and want your invoices to print with a tentative delivery date. You ship UPS. If an appropriate web service is running at UPS you can issue a request and receive the information you need.

  9. Web Services: Why? (2) • How about determining tax on an invoice when you ship to multiple states? You can (1) maintain all the tax tables and rules yourself on your system or (2) issue calls to web services in each of the states to get the information you need. Always up to date and correct. • As the web gets faster, web services get more practical for any type of computing.

  10. How do I make one? • Well, in practice you just click on the web service icon in the .NET IDE. • That brings up template web service code that has two required syntactic elements: • A web services namespace declaration • A <webmethod>directive for each function in the web service (one service can implement multiple functions)

  11. Web service namespace declaration Imports System.Web.Services <System.Web.Services.WebService(Namespace:="http://Walkthrough/XmlWebServices/", _ Description:="A temperature conversion service.")> _ Public Class Service1 Inherits System.Web.Services.WebService Note continuations

  12. <webmethod> directives (TempConvert1.vb) <WebMethod(Description:="This method converts a temperature in " & _ "degrees Fahrenheit to a temperature in degrees Celsius.")> _ Public Function ConvertTemperature(ByVal dFahrenheit As Double) As Double Return ((dFahrenheit - 32) * 5) / 9 End Function Note continuation

  13. Deploying web services • The web service code is “built” just as any other .NET project code. The web service code file extension is .asmx • The web service does not need to be run on the development machine. Instruction for moving the compiled web service are given in the MSDN document: Creating an XML Web Service Using Visual Basic or Visual C# • This document is part of the web services lab

  14. Accessing web services (1) (see Web.config) • To access a web service you add a Web Reference to any .NET project. • In Solution Explorer, right click on the project and then click on Add Web Reference • A screen will appear asking you for the URL of the service: • http://134.197.65.27/TempConvert1/Service1.asmx Service name Machine IP address Virtual directory of the web service

  15. Accessing web services (2) • In order for the completed web service reference to function: • The URL must be exact • The machine running the web service must be on and IIS must be running • The web service must have compiled correctly • The client and host must both be connected to the web

  16. Accessing web services (3) • A single web service project can contain multiple web accessible functions – each identified by the <webMethod> syntax • Before you can access a function you must: • (1) declare and create an object of type <yourServiceName> • (2) invoke the function as a method of the object, i.e. <yourServiceName>.<your function>

  17. Accessing web services (4) (WebForm1.aspx) • AFTER including Service1 as a Web Reference in your project • Example syntax for declaration • Dim ws As New ConvertSvc.Service1 • Example syntax for function use • dCelsius = ws.ConvertTemperature(dFahrenheit) The name of the .asmx The name of the web reference The name you gave the webMethod inside Service1

  18. But wait – there’s more!! • SOAP (Simple Object Access Protocol) • UDDI (Universal Description, Discovery and Integration Service) • WSDL (Web Service Description Language) • And a host of other acronyms we won’t even briefly discuss: XLANG, XAML, XKMS, ADS, XFS . . .

  19. SOAP • SOAP is a protocol specification that defines a uniform way of passing XML-encoded data • Given XML is the “language” for web service messages, SOAP is a set of rules for constructing those messages. • For more information, check the index of your IDE or just GOOGLE “SOAP tutorial”

  20. UDDI (1) • UDDI(Universal Description, Discovery and Integration Service) is more vision than reality currently, but what a vision! • Imagine a search engine for web services – a way to “look up” what services are available, what they do and where they are – that’s UDDI

  21. UDDI (2) • Creators of web services publish their services to web-based directories: • Service information directory sometimes called the Yellow Pages (broad categorization) • Business information directory, sometimes called the White Pages (specific information on a service) • To find out more, GOOGLE “UDDI tutorial”

  22. WSDL • OK – assuming these web-accessible directories exist, how do I go about precisely describing my web service?: • What it does • What parameters it requires • What information it returns • This requires YAL (yet another language) WSDL (Web Service Description Language) • DEMO: TempConvert1.disco & TempConvert1.wsdl • To find out more, GOOGLE “WSDL tutorial”

More Related