Exforsys

VB.NET 2005

  1. VB.NET 2005 Free Training
  2. The .NET Framework Architecture Part 1
  3. The .NET Framework Architecture Part 2
  4. Application Class and Message Class
  5. Implementing Class Library Object
  6. Visual Studio.NET Namespaces
  7. .NET Assemblies
  8. Differences between VB.NET 1.0 and VB.NET 2.0
  9. Introducing VB.NET Windows Forms
  10. Visual Studio Windows Forms Designer
  11. Exploring the Forms Designer generated code
  12. Setting and Adding Properties to Windows Form
  13. Implementing Inheritance
  14. Event Handling In Visual Basic .NET
  15. Building Graphical Interface elements
  16. .NET Common Windows Forms Controls Part 1
  17. .NET Common Windows Forms Controls Part 2
  18. Common Controls and Handling Control Events
  19. DomainUpDown and NumericUpDown Controls
  20. Dialog Boxes in Visual Basic .NET
  21. Visual Studio Adding Controls to Windows Form
  22. VB.NET Validation Controls
  23. Working with Menu Controls
  24. VB.NET MDI Applications
  25. .NET Exceptions
  26. VB.NET Creating and Managing Components Part 1
  27. VB.NET Creating and Managing Components Part 2
  28. Simple Data Binding
  29. .NET Complex Data Binding
  30. .NET Data Form Wizard
  31. Data Manipulation with ADO.NET
  32. SQL Server Stored Procedures
  33. SQL Server Ad Hoc Queries
  34. Finding and Sorting Data in DataSets
  35. ADO.NET Object Model
  36. Working with DataSets
  37. Using XML Data
  38. Working with File System in .NET
  39. Creating Web Service
  40. Instantiating - Invoking Web Services, Creating Proxy Classes with WSDL
  41. Web Reference and Web Services
  42. Web Services - SOAP, WSDL, Disco and UDDI
  43. Web Application Testing in VB.NET 2005
  44. Web Application Tracing and Debugging
  45. Working with Legacy Code and COM Components
  46. ActiveX Controls and Legacy Code
  47. Windows Application Testing
  48. VB.NET Windows Application Testing
  49. Tracing VB.NET Windows Application
  50. Debugging Windows Applications In Visual Studio.NET 2005
  51. Deploying Windows Applications In Visual Studio.NET 2005
  52. Customizing Setup Project in Visual Studio.NET 2005
  53. Shared Assembly
  54. Microsoft .NET Creating Installation Components
  55. The Registry Editor in Visual Studio.NET 2005
  56. The File Types Editor

Ads


Home arrow Technical Training arrow VB.NET 2005

Web Reference and Web Services

Author : Exforsys Inc.     Published on: 16th Jul 2005    |   Last Updated on: 24th Dec 2007

In this tutorial you will learn about Using Web Reference - Adding a Web reference:, To create an ASP.NET Web application, Adding a Web Reference, Testing a Web Service, Accessing the XML Web Service and To access the XML Web service

Ads

VB.NET 2005 Tutorials : Web Reference, ASP.NET Web Application and XML Web Service

Using Web Reference

A Web reference is a generated proxy class that locally represents the exposed functionality of an XML web service. The proxy class defines methods that represent the actual methods exposed by an XML web service. When the client application creates an instance of the proxy class, it is capable of calling the XML Web service methods as if the XML Web service were a locally available component. The programming language the proxy class is generated, is dependent upon the programming language of the active project to which the Web reference is added. However if you created a proxy using the tool wsdl.exe, you have the option to provide the program language.

At design time, the added reference enables the developer use the statement completion in the code editor using the IntelliSense. The actual implementation of the methods in the proxy class is comprised of code to package and send SOAP request message and to receive and un package any returned SOAP response message.

At run time, a call to a method of the proxy object is processed and encoded as a SOAP request message if the SOAP protocol is supported. If the XML Web service does not support SOAP, the proxy uses HTTP POST or HTTP GET. This message is then sent to the actual Web Service for processing.

Adding a Web reference:

a.Testing a Web Service

  • Create a client application using the ASP.NET Web Application project template.
  • Add a Web reference for an XML Web service.
  • Write code to access the XML Web service.
  • Run the Web application in debug mode.
  • Deploy the Web application.

If the name of the temperature conversion XML Web service was changed after creation substitute the appropriate names where the TempConvert1 name appears throughout this walkthrough.

To create an ASP.NET Web application

1.File menu, choose New Web Site.
2.New Web Site dialog box, select the ASP.NET Web Site icon.
3.http://vbdotnet/client .By default, the project uses your local machine, http://localhost.
4
.OK to create the project.
5.Solution Explorer, right-click Default.aspx and choose View Designer to open the designer.
6.Web Forms tab of the Toolbox, drag a Text Box, five Labels, and a Button to the design surface of Default.aspx and arrange them to your liking.
7.Button1, and click Properties on the shortcut menu. In the Properties window, set the Text property to Convert.
8.Label1, and click Properties on the shortcut menu. In the Properties window, clear the Text property to make this a blank label.

Adding a Web Reference

1.Website menu, choose Add Web Reference.
2.URL box of the Add Web Reference dialog box, type the URL to obtain the service description of the XML Web service you want to access, such as http://vbdotnet/Service.asmx. Then click the Go button to retrieve information about the XML Web service.

Visual Studio downloads the service description and generates a proxy class to interface between your application and the XML Web service.

Accessing the XML Web Service

Once a reference for the XML Web service is added to the project, the next step is to create an instance of the XML Web service's proxy class. The user can then access the methods of the XML Web service in the same manner that he accesses any object's methods by calling methods in the proxy class. When the application calls these methods, the proxy class code generated by Visual Studio handles the communications between the application and the XML Web service.

a.TextBox1, and make a call to the XML Web service's ConvertTemperature method using the proxy class.
c.To access the XML Web service

1.Convert button on WebForm1.aspx to create an event-handling method for this button and to display the code-behind file.
2. 

 

Class Default_aspx

Inherits System.Web.UI.Page

 

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim wsConvert As New vbdotnet.Service()

Dim temperature As Double

Try

temperature = Convert.ToDouble(TextBox1.Text)

Label2.Text = _

wsConvert.FahrenheitToCelsius(temperature).ToString()

Label5.Text = _

wsConvert.CelsiusToFahrenheit(temperature).ToString()

Catch

 

End Try

End Sub

Class

The name of the XML Web service class generated when adding a Web reference may differ from the one shown above as Service.
3.Default.aspx in Solution Explorer.
4.Website menu, click Set as Start Page.
5.Now open the site http://vbdotnet/client/default.aspx in a browser. The site in the browser looks like the graphic shown below:

Ads

A value can be entered in the text box. This value is passed to the two methods defined in the web service. The value is considered as Fahrenheit and changed to Celsius by one method and vice versa in the other method. Now enter a value 200 in the text box and find the result:

In this lesson we have covered all aspects of using Web services in the .NET framework. We have learnt how to create and deploy a web service. In the next lesson we shall look at some of the aspects of testing and debugging a Web application.

 



 
This tutorial is part of a VB.NET 2005 tutorial series. Read it from the beginning and learn yourself.

VB.NET 2005

  1. VB.NET 2005 Free Training
  2. The .NET Framework Architecture Part 1
  3. The .NET Framework Architecture Part 2
  4. Application Class and Message Class
  5. Implementing Class Library Object
  6. Visual Studio.NET Namespaces
  7. .NET Assemblies
  8. Differences between VB.NET 1.0 and VB.NET 2.0
  9. Introducing VB.NET Windows Forms
  10. Visual Studio Windows Forms Designer
  11. Exploring the Forms Designer generated code
  12. Setting and Adding Properties to Windows Form
  13. Implementing Inheritance
  14. Event Handling In Visual Basic .NET
  15. Building Graphical Interface elements
  16. .NET Common Windows Forms Controls Part 1
  17. .NET Common Windows Forms Controls Part 2
  18. Common Controls and Handling Control Events
  19. DomainUpDown and NumericUpDown Controls
  20. Dialog Boxes in Visual Basic .NET
  21. Visual Studio Adding Controls to Windows Form
  22. VB.NET Validation Controls
  23. Working with Menu Controls
  24. VB.NET MDI Applications
  25. .NET Exceptions
  26. VB.NET Creating and Managing Components Part 1
  27. VB.NET Creating and Managing Components Part 2
  28. Simple Data Binding
  29. .NET Complex Data Binding
  30. .NET Data Form Wizard
  31. Data Manipulation with ADO.NET
  32. SQL Server Stored Procedures
  33. SQL Server Ad Hoc Queries
  34. Finding and Sorting Data in DataSets
  35. ADO.NET Object Model
  36. Working with DataSets
  37. Using XML Data
  38. Working with File System in .NET
  39. Creating Web Service
  40. Instantiating - Invoking Web Services, Creating Proxy Classes with WSDL
  41. Web Reference and Web Services
  42. Web Services - SOAP, WSDL, Disco and UDDI
  43. Web Application Testing in VB.NET 2005
  44. Web Application Tracing and Debugging
  45. Working with Legacy Code and COM Components
  46. ActiveX Controls and Legacy Code
  47. Windows Application Testing
  48. VB.NET Windows Application Testing
  49. Tracing VB.NET Windows Application
  50. Debugging Windows Applications In Visual Studio.NET 2005
  51. Deploying Windows Applications In Visual Studio.NET 2005
  52. Customizing Setup Project in Visual Studio.NET 2005
  53. Shared Assembly
  54. Microsoft .NET Creating Installation Components
  55. The Registry Editor in Visual Studio.NET 2005
  56. The File Types Editor
 

Comments