Using Web Services with VB.NET

Web Services is one of the greatest technologies developed in the Internet world. They can be used to connect businesses with each other and clients in a standard way using XML (Extensible Markup Language), SOAP (Simple Object Access Protocol), WSDL (Web Services Description Language), and UDDI (Universal Description, Discovery and Integration).

XML is used for structuring the data, SOAP is used to transfer the data, WSDL is used for describing the services, and UDDI is used to get a list of services available. Web Services allows applications to communicate with each other without worrying about their hardware systems, operating systems, and programming languages.

Unlike the older model, Web Services does not provide a user interface but exposes the business logic, which can be programmed; therefore, the user is free to add his own interface to the application.

Google is one of the Web sites that has provided a public Web Services, allowing applications to use features such as search and spell checks. We shall now see how can we use this service in our application using Visual Basic .NET.

But before we can access Google's Web APIs service, we will have to create a Google account and obtain an license key that will allow us to run about 1,000 automated queries a day. Please visit http://www.Google.co.nz/apis/ to create a Google account. After you have entered your e-mail address and password, Google will mail you a license key, which we'll use in our application.

Getting Started

Now that you have received your license key, we will create an application in Visual Basic .NET to create a customized search and a spelling checker that uses the Google Web APIs Service.

Open your Visual Studio .NET, create a new Windows Application Project, which we will call googleapi, and then click OK.

Adding a Web Reference to Google Web APIs Service

We will now add a Web Reference to Google Web APIs Service. Well, this is almost like adding a reference to a COM/ActiveX object, but when we add a Web Reference we now have access to all the XML Web Services on the Google server. Open your Solution Explorer, right-click References, and then click Add Web Reference. Alternatively, you could select Project menu and click Add Web Reference.

In the Add Web Reference window, type http://api.Google.com/GoogleSearch.wsdl in the address bar. Please make sure you type exactly as shown; this URL is case sensitive.

After you enter the URL and press Enter, the Google Web Service is loaded. You should see a screen like Figure 2. Also, the Add Reference button is enabled. Click Add Reference button to add this Web reference to our project.

In the Solution Explorer Window, click the Web Reference to see a Google Web Reference, which we have added. Let's rename that to Google by right-clicking it and clicking Rename.

Create a User Interface as shown below with the flowing controls and given names.

Finally

Now we have finished coding our application. Run the application and type some text to search in the text box. Click the Google Search button to see the number of results found. Also, try the Google spell check.

About the Author

Jayesh Jain works as a consultant in Auckland, New Zealand. He has several years of n-Tier development experience and is currently working with Visual Basic.NET to develop interactive client solutions. He has a passion for Web development and in his spare time he likes to write articles. You can contact him here.

Top White Papers and Webcasts

Live Event Date: March 19, 2015 @ 1:00 p.m. ET / 10:00 a.m. PT
The 2015 Enterprise Mobile Application Survey asked 250 mobility professionals what their biggest mobile challenges are, how many employees they are equipping with mobile apps, and their methods for driving value with mobility.
Join Dan Woods, Editor and CTO of CITO Research, and Alan Murray, SVP of Products at Apperian, as they break down the results of this survey and discuss how enterprises are using mobile application management and private …

On-demand Event
Event Date: February 12, 2015
The evolution of systems engineering with the SysML modeling language has resulted in improved requirements specification, better architectural definition, and better hand-off to downstream engineering. Agile methods have proven successful in the software domain, but how can these methods be applied to systems engineering? Check out this webcast and join Bruce Powel Douglass, author of Real-Time Agility, as he discusses how agile methods have had a tremendous …