Presentation is loading. Please wait.

Presentation is loading. Please wait.

© 2009 Dr. Paul Walcott – The University of the West Indies: Cave Hill CampusDr. Paul Walcott COMP6325 Advanced Web Technologies Dr. Paul Walcott The University.

Similar presentations


Presentation on theme: "© 2009 Dr. Paul Walcott – The University of the West Indies: Cave Hill CampusDr. Paul Walcott COMP6325 Advanced Web Technologies Dr. Paul Walcott The University."— Presentation transcript:

1 © 2009 Dr. Paul Walcott – The University of the West Indies: Cave Hill CampusDr. Paul Walcott COMP6325 Advanced Web Technologies Dr. Paul Walcott The University of the West Indies Session 6 – Building Enterprise-scale Web- based Applications – Part V : Web Services Spring 2009

2 © 2009 Dr. Paul Walcott – The University of the West Indies: Cave Hill CampusDr. Paul Walcott Objectives At the end of this session the student shall be able to: Describe a web service Create a simple web service

3 © 2009 Dr. Paul Walcott – The University of the West Indies: Cave Hill CampusDr. Paul Walcott An ASP.NET application comprises of (MacDonald 2007, p. 130) :

4 © 2009 Dr. Paul Walcott – The University of the West Indies: Cave Hill CampusDr. Paul Walcott Web services Used primarily as a means for businesses to communicate with each other and with clients, Web services allow organizations to communicate data without intimate knowledge of each other's IT systems behind the firewall. http://www.webopedia.com/TERM/W/Web_services.htm

5 © 2009 Dr. Paul Walcott – The University of the West Indies: Cave Hill CampusDr. Paul Walcott Web services contd Web services use a variety of technologies ( http://www.webopedia.com/TERM/W/Web_services.htm ): http://www.webopedia.com/TERM/W/Web_services.htm Extensible markup language (XML) – to describe the data Simple object access protocol SOAP (SOAP) – to transport the data Web Service definition language (WSDL) Describes the capabilities of the Web Service Universal description, discovery and integration (UDDI) – to list the available services Hypertext Transfer Protocol (HTTP) – rules for transferring files over the Internet

6 © 2009 Dr. Paul Walcott – The University of the West Indies: Cave Hill CampusDr. Paul Walcott Creating a Web Service (Singh 2002) As a simple example let us create a Calculator Web Service which: Provides a description of the services offered Multiplies two integers Click here to get the two files required for our example: Click here Service.asmx (the web service) and multiply.cs (our consumer)

7 © 2009 Dr. Paul Walcott – The University of the West Indies: Cave Hill CampusDr. Paul Walcott What is the first step when creating a Web Service? Create a virtual directory that will be used to store your Web Service (Control Panel | Administrative Tools | Internet Information Services) For our example call the virtual directory Calculator

8 © 2009 Dr. Paul Walcott – The University of the West Indies: Cave Hill CampusDr. Paul Walcott The Second step is to create the actual service that you want to provide Our Web Service is stored in the file S ervice.asmx (the.asmx extension is used by Web Services): The WebService page directive defines the Web Service The name space of the Web Service is specified using [WebService(Namespace="http://localhost /Calculator/")] Each method provided by the Web Service begins with [WebMethod]

9 © 2009 Dr. Paul Walcott – The University of the West Indies: Cave Hill CampusDr. Paul Walcott The third step is to publish the service Since we have already created a virtual directory and copied service.asmx into it, we have already published our service To test our service simply type http://localhost/Calculator/Se rvice.asmx http://localhost/Calculator/Se rvice.asmx This returns a web page with a description of the services that are offered

10 © 2009 Dr. Paul Walcott – The University of the West Indies: Cave Hill CampusDr. Paul Walcott Supposed someone want to use our Calculator Service? Anyone wanting to use our service will need to write a Web Service consumer, either: A Web-based Service Consumer, or A Windows Application-Based Web Service Consumer For simplicity we will create a Windows Application-Based Web Service Consumer Building a Web-based Service Consumer is also easy

11 © 2009 Dr. Paul Walcott – The University of the West Indies: Cave Hill CampusDr. Paul Walcott Next, we have to write proxy for the Web Service that is being consumed The WSDL utility is used (at the command prompt) WSDL http://localhost:8080/Calculator/servic e.asmx?WSDL This creates a proxy (an intermediary between our application and the Web Service) Calculator.cs is created which contains the proxy code We now need to create a DLL for the proxy (Calculator.dll) csc /target:library Calculator.cs

12 © 2009 Dr. Paul Walcott – The University of the West Indies: Cave Hill CampusDr. Paul Walcott What does the proxy do? The proxy takes care of all the communication between our application and the Web Service This includes the use of the SOAP and WSDL protocols

13 © 2009 Dr. Paul Walcott – The University of the West Indies: Cave Hill CampusDr. Paul Walcott Compiling the consumer Now that the dll for the proxy has been created all that is left to be done is to compile the consumer with the proxy: csc /reference:Calculator.dll multiply.cs

14 © 2009 Dr. Paul Walcott – The University of the West Indies: Cave Hill CampusDr. Paul Walcott Running the application To run the newly created multiply application which utilises the calculator web service simply type: > multiply 2 3 The result returned is 2 * 3 = 6

15 © 2009 Dr. Paul Walcott – The University of the West Indies: Cave Hill CampusDr. Paul Walcott Conclusion In this session The term Web Service was defined A simple Calculator Web service was created

16 © 2009 Dr. Paul Walcott – The University of the West Indies: Cave Hill CampusDr. Paul Walcott References Platt, D., Introducing Microsoft.NET, Third Edition, Microsoft Press, 2003 Ruvalcaba, Z., Build Your Own ASP.NET Website Using C# And VB.NET, Chapter 1 – Introduction to.NET and ASP.NET, 2004. Available online at http://www.sitepoint.com/print/asp-dot-net-introductionhttp://www.sitepoint.com/print/asp-dot-net-introduction Ruvalcaba, Z., Build Your Own ASP.NET Website Using C# And VB.NET, Chapter 2 – ASP.NET Basics, 2004. Available online at http://www.sitepoint.com/print/asp-dot-net-basicshttp://www.sitepoint.com/print/asp-dot-net-basics Singh, S,.NET Web Services Tutorial, 2002. Available online at http://www.codeguru.com/Csharp/Csharp/cs_webservices/tutorials/article.php/c5477 W3Schools, Web Services Tutorial, nd. Available online at http://www.w3schools.com/webservices/default.asp http://www.w3schools.com/webservices/default.asp


Download ppt "© 2009 Dr. Paul Walcott – The University of the West Indies: Cave Hill CampusDr. Paul Walcott COMP6325 Advanced Web Technologies Dr. Paul Walcott The University."

Similar presentations


Ads by Google