Logo

Navigation
  • Home
  • Services
    • ERP Solutions
    • Implementation Solutions
    • Support and Maintenance Solutions
    • Custom Solutions
    • Upgrade Solutions
    • Training and Mentoring
    • Web Solutions
    • Production Support
    • Architecture Designing
    • Independent Validation and Testing Services
    • Infrastructure Management
  • Expertise
    • Microsoft Development Expertise
    • Mobile Development
    • SQL Server Database and BI
    • SAP BI, SAP Hana, SAP BO
    • Oracle and BI
    • Oracle RAC
  • Technical Training
    • Learn Data Management
      • Business Intelligence
      • Data Mining
      • Data Modeling
      • Data Warehousing
      • Disaster Recovery
    • Learn Concepts
      • Application Development
      • Client Server
      • Cloud Computing Tutorials
      • Cluster Computing
      • CRM Tutorial
      • EDI Tutorials
      • ERP Tutorials
      • NLP
      • OOPS
      • Concepts
      • SOA Tutorial
      • Supply Chain
      • Technology Trends
      • UML
      • Virtualization
      • Web 2.0
    • Learn Java
      • JavaScript Tutorial
      • JSP Tutorials
      • J2EE
    • Learn Microsoft
      • MSAS
      • ASP.NET
      • ASP.NET 2.0
      • C Sharp
      • MS Project Training
      • Silverlight
      • SQL Server 2005
      • VB.NET 2005
    • Learn Networking
      • Networking
      • Wireless
    • Learn Oracle
      • Oracle 10g
      • PL/SQL
      • Oracle 11g Tutorials
      • Oracle 9i
      • Oracle Apps
    • Learn Programming
      • Ajax Tutorial
      • C Language
      • C++ Tutorials
      • CSS Tutorial
      • CSS3 Tutorial
      • JavaScript Tutorial
      • jQuery Tutorial
      • MainFrame
      • PHP Tutorial
      • VBScript Tutorial
      • XML Tutorial
    • Learn Software Testing
      • Software Testing Types
      • SQA
      • Testing
  • Career Training
    • Career Improvement
      • Career Articles
      • Certification Articles
      • Conflict Management
      • Core Skills
      • Decision Making
      • Entrepreneurship
      • Goal Setting
      • Life Skills
      • Performance Development
      • Personal Excellence
      • Personality Development
      • Problem Solving
      • Relationship Management
      • Self Confidence
      • Self Supervision
      • Social Networking
      • Strategic Planning
      • Time Management
    • Education Help
      • Career Tracks
      • Essay Writing
      • Internship Tips
      • Online Education
      • Scholarships
      • Student Loans
    • Managerial Skills
      • Business Communication
      • Business Networking
      • Facilitator Skills
      • Managing Change
      • Marketing Management
      • Meeting Management
      • Process Management
      • Project Management
      • Project Management Life Cycle
      • Project Management Process
      • Project Risk Management
      • Relationship Management
      • Task Management
      • Team Building
      • Virtual Team Management
    • Essential Life Skills
      • Anger Management
      • Anxiety Management
      • Attitude Development
      • Coaching and Mentoring
      • Emotional Intelligence
      • Stress Management
      • Positive Thinking
    • Communication Skills
      • Conversation Skills
      • Cross Culture Competence
      • English Vocabulary
      • Listening Skills
      • Public Speaking Skills
      • Questioning Skills
    • Soft Skills
      • Assertive Skills
      • Influence Skills
      • Leadership Skills
      • Memory Skills
      • People Skills
      • Presentation Skills
    • Finding a Job
      • Etiquette Tips
      • Group Discussions
      • HR Interviews
      • Interview Notes
      • Job Search Tips
      • Resume Tips
      • Sample Resumes
 

Web Reference and Web Services

By Exforsys | on July 16, 2005 |
VB.NET 2005

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

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. In solution Explorer, choose the project that will consume the web service
b. Right click on the project to bring the context menu.
c. Choose Add Web Reference in the menu, to open the dialog box.
d. Select the link in the Web browser pane on the left to search for web services installedon your local machine, or available on servers within the intranet or available from the providers of commercial Web services listed in the UDDI Business Directory.
e. Select a Web service from the services listed in the web browser pane on the left. The path to the selected Web services appears in the URL field. You may have to make additional setting if you are behind a fire wall.
f. Check for the security.
g. Enter a name of choice, which will be used in your code to access the selected Web service, in the Web Reference name field.
h. Now click on the Add reference button to add reference name.
i. Check the Webreference folder in the solution explorer for the namespace for the Web reference classes that are available to the items in your project.
j. Now your web reference is ready to use.

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. On the File menu, choose New Web Site.
2. In the New Web Site dialog box, select the ASP.NET Web Site icon.
3. Enter the address of the Web server on which you will develop the Web application in this case I have chosen
http://vbdotnet/client .By default, the project uses your local machine, http://localhost.
4
. Click OK to create the project.
5. In Solution Explorer, right-click Default.aspx and choose View Designer to open the designer.
6. From the 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. Right-click the button you added, Button1, and click Properties on the shortcut menu. In the Properties window, set the Text property to Convert.
8. Right-click the label you added, 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. On the Website menu, choose Add Web Reference.
2. In the 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. First, we will create an instance of the XML Web service’s proxy class.
b. Next, we will take a value, provided in TextBox1, and make a call to the XML Web service’s ConvertTemperature method using the proxy class.
c. Then we will display the value returned from the XML Web service.

To access the XML Web service

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

 

 

Partial 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

End 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. Select Default.aspx in Solution Explorer.
4. On the Website menu, click Set as Start Page.
5. Save the solution.

Now open the site http://vbdotnet/client/default.aspx in a browser. The site in the browser looks like the graphic shown below:

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.

 

« « Creating Web Service
Creating New Forms in Oracle Apps 11i » »

Author Description

Avatar

Editorial Team at Exforsys is a team of IT Consulting and Training team led by Chandra Vennapoosa.

Free Training

RSSSubscribe 394 Followers
  • Popular
  • Recent
  • Debugging Windows Applications In Visual Studio.NET 2005

    August 3, 2005 - 0 Comment
  • Visual Studio Windows Forms Designer

    June 7, 2005 - 0 Comment
  • .NET Assemblies

    July 7, 2005 - 0 Comment
  • .NET Common Windows Forms Controls Part 2

    July 2, 2005 - 0 Comment
  • Using XML Data

    July 14, 2005 - 0 Comment
  • Customizing Setup Project in Visual Studio.NET 2005

    August 4, 2005 - 0 Comment
  • Exploring the Forms Designer generated code

    June 7, 2005 - 0 Comment
  • Simple Data Binding

    July 7, 2005 - 0 Comment
  • Working with Menu Controls

    July 3, 2005 - 0 Comment
  • Web Services – SOAP, WSDL, Disco and UDDI

    July 16, 2005 - 0 Comment
  • Microsoft .NET Creating Installation Components

    August 10, 2005 - 0 Comment
  • Shared Assembly

    August 9, 2005 - 0 Comment
  • The File Types Editor

    August 9, 2005 - 0 Comment
  • Tracing VB.NET Windows Application

    August 9, 2005 - 0 Comment
  • VB.NET Windows Application Testing

    August 9, 2005 - 0 Comment
  • The Registry Editor in Visual Studio.NET 2005

    August 4, 2005 - 0 Comment
  • Customizing Setup Project in Visual Studio.NET 2005

    August 4, 2005 - 0 Comment
  • Deploying Windows Applications In Visual Studio.NET 2005

    August 3, 2005 - 0 Comment
  • Debugging Windows Applications In Visual Studio.NET 2005

    August 3, 2005 - 0 Comment
  • Working with Legacy Code and COM Components

    July 30, 2005 - 0 Comment

Exforsys e-Newsletter

ebook
 

Related Articles

  • Microsoft .NET Creating Installation Components
  • Shared Assembly
  • The File Types Editor
  • Tracing VB.NET Windows Application
  • VB.NET Windows Application Testing

Latest Articles

  • Project Management Techniques
  • Product Development Best Practices
  • Importance of Quality Data Management
  • How to Maximize Quality Assurance
  • Utilizing Effective Quality Assurance Strategies
  • Sitemap
  • Privacy Policy
  • DMCA
  • Trademark Information
  • Contact Us
© 2023. All Rights Reserved.IT Training and Consulting
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish.AcceptReject Read More
Privacy & Cookies Policy

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Non-necessary
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SAVE & ACCEPT