Web Service Project (.NET) Dr. Dante Ciolfi (chawl fee)
Transcript of Web Service Project (.NET) Dr. Dante Ciolfi (chawl fee)
Web Service Project (.NET)
Dr. Dante Ciolfi (chawl fee)
Overview
• Materials required• Create a Web Forms site• Expose a Web service – temperature converter• Create a data consumer for above service• Adjustments to code provided by Visual Studio
Materials required
• Visual Studio 2013 (2012 may work)• File named code.txt
Create a Web Forms site
• Create a ASP.NET Web Forms site (VB) called TempConvert• Add item: TempConvert.asmx• TempConvert.asmx: add code: Imports System.Web• Add reference to project: Debug > TempConvert Properties > add
System Web
Expose a Web service
• Add code to TempConvert.asmx.vb (see code.txt)
Create a data consumer for above service• Add item: WebForm1.aspx (with WebForm1.aspx.vb)• Add code to above file (use code.txt)
Adjustments to code provided by Visual Studio• TempConvert.asmx.vb:
• Change Namespace reference: instead of “uri”, use tempconvert + your initials, e.g., tempconvertdc.org (a unique name is needed here)
• WebForm1.aspx:• Value of action attribute: use file name and function, e.g.,
‘TempConvert.asmx/FahrenheitToCelsius’
• WebForm1.aspx.vb:• rURL line: use complete address, e.g., http://localhost:17388/TempConvert.asmx
(hint: run your app to check the port)• Button1.CommitTransaction (use CommitTransaction, not Click)• Error: “Handles clause requires a WithEvents…”: place the following code above
Protected Sub Button1_Click…: Public WithEvents Button1 As UserControl
Summary
• Materials required• Create a Web Forms site• Expose a Web service – temperature converter• Create a data consumer for above service• Adjustments to code provided by Visual Studio
Credits
Resources: (accessed 11/11/2013)-----------------------Web service example:http://wwwht.w3schools.com/webservices/ws_example.aspRedirect to a URL via VB:http://www.infopathdev.com/forums/p/11646/41098.aspxHandles clause requires a WithEvents...:http://social.msdn.microsoft.com/Forums/vstudio/en-US/45889a1c-b14e-45ba-99e1-ee87c8b1facd/handles-clause-requires-a-withevents-variable-defined-in-the-containing-type-or-one-of-its-base?forum=vbgeneral