1 / 16

COMP6325 Advanced Web Technologies

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. Objectives. At the end of this session the student shall be able to: Describe a web service

junius
Download Presentation

COMP6325 Advanced Web Technologies

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. 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. Objectives • At the end of this session the student shall be able to: • Describe a web service • Create a simple web service

  3. An ASP.NET application comprises of (MacDonald 2007, p. 130):

  4. 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. Web services cont’d • Web services use a variety of technologies (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. 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: • Service.asmx (the web service) and • multiply.cs (our consumer)

  7. 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. The Second step is to create the actual service that you want to provide • Our Web Service is stored in the file Service.asmx (the .asmx extension is used by Web Services): • The WebService page directive <%@ WebService language="C#" class="Calculator" %> 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. 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/Service.asmx • This returns a web page with a description of the services that are offered

  10. 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. 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/service.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. 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. 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. 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. Conclusion • In this session • The term Web Service was defined • A simple Calculator Web service was created

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

More Related