asp tutorials, asp.net tutorials, sample code, and Microsoft news from 15Seconds
Data Access  |   Troubleshooting  |   Security  |   Performance  |   ADSI  |   Upload  |   Email  |   Control Building  |   Component Building  |   Forms  |   XML  |   Web Services  |   ASP.NET  |   .NET Features  |   .NET 2.0  |   App Development  |   App Architecture  |   IIS  |   Wireless
 
Pioneering Active Server
 Power Search








Active News
15 Seconds Weekly Newsletter
• Complete Coverage
• Site Updates
• Upcoming Features

More Free Newsletters
Reference
News
Articles
Archive
Writers
Code Samples
Components
Tools
FAQ
Feedback
Books
Links
DL Archives
Community
Messageboard
List Servers
Mailing List
WebHosts
Consultants
Tech Jobs
15 Seconds
Home
Site Map
Press
Legal
Privacy Policy
internet.commerce














internet.com
IT
Developer
Internet News
Small Business
Personal Technology
International

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers

HardwareCentral
Compare products, prices, and stores at Hardware Central!

Accessing Caller ID from the Web - Part 2
By Paul Apostolos
Rating: 3.9 out of 5
Rate this article


  • email this article to a colleague
  • suggest an article

    Introduction

    In part 1 I built a VB6 program to insert incoming caller id information into an SQL server database. In order to have the information available online, I'm going to have to write some kind of Web page to retrieve the data from the database.

    I could write a simple ASP page and be done with it, but, instead, I'm going to build an ASP.NET Web service that will expose methods for getting and manipulating the data.

    Since I plan on developing a desktop version of the application as well, a Web service will allow both versions to have the same funtionality while only having to write the code once.

    The Code

    
    <%@ WebService Language="vb" Class="Caller_Id" %>  
    
    Imports System
    Imports System.Data
    Imports System.Data.SqlClient
    Imports System.Web.Services  
    Imports System.Configuration
    
    '// When declaring a namespace for your Web service
    '// Choose something that will be a unique identifier
    '// Notice how I used the domain name that I own
    
    <WebService(Namespace:="www.allpaul.com")> _
    Public Class Caller_Id
    
    <WebMethod> Public Function Get_Callers() As Dataset
    	try
    		Dim myConnection As SqlConnection
    		Dim myCommand As SqlDataAdapter
    		myConnection = New _
    			SqlConnection(ConfigurationSettings.AppSettings("MyDSN"))
    					
    		myCommand = New _
    			SqlDataAdapter("sp_GetCallers", myConnection)
    					
    		myCommand.SelectCommand.CommandType = _
    			CommandType.StoredProcedure
    					
    		myConnection.Open()
    											
    		Dim myDataSet As New DataSet()
    		
    		myCommand.Fill(myDataSet, "tbl_Caller_Id")
    					
    		myConnection.Close
    					
    		Return myDataSet
    				
    	catch exp As Exception
    					
    		Return nothing
    					
    	End try
      	End Function
    
    	<WebMethod>	Public Sub Delete_Caller(Caller_Id as Integer)
    				
    	Dim myConnection As _
    		New SqlConnection(ConfigurationSettings.AppSettings("MyDSN"))
    				
    	Dim myCommand As _
    		New SqlCommand("sp_DeleteCaller", myConnection)
    
    	myCommand.CommandType = CommandType.StoredProcedure
    				
    	Dim parameterCaller_Id As _
    		New SqlParameter("@Caller_ID", SqlDbType.Int, 4)
    				
    	parameterCaller_Id.Value = Caller_Id
    	myCommand.Parameters.Add(parameterCaller_Id)
    
    	myConnection.Open()
    		myCommand.ExecuteNonQuery()
    	myConnection.Close()
    			
    End Sub
    End Class
    
    
    Any method in a class can be called via a Web service request as long as <WebMethod> appears before the declaration of the method.

    This service has two WebMethods:

    Get_Callers

    This method accepts no parameters and returns all the callers from the database as a dataset to the page that calls the method. It uses a stored procedure, sp_GetCallers, that simply retrieves all the records from the table tbl_Caller_id.

    
    CREATE PROCEDURE sp_GetCallers
    AS
    
    Select * From tbl_Caller_Id Order By Call_Date
    GO
    
    
    Delete_Caller

    This method used to delete a specific caller from the database. The method expects an integer Caller_ID and uses the stored procedure sp_DeleteCaller passing it the input parameter Caller_ID.

    
    CREATE PROCEDURE sp_DeleteCaller
    (
    	@Caller_ID int
    )
    
    AS
    
    Delete From tbl_Caller_Id WHERE ID = @Caller_ID
    GO
    
    

    To test the service, navigate to the URL using any Web browser. Conveniently, Web services are served to Web browsers as html interfaces. So, if you navigate to the service you should see a page similar to the following screenshot.

    And, clicking on the links named for each of the services Web methods allows you to invoke the method (if parameters are expected you will be prompted to provide them) and view the results.

    Get_Callers:

    The resulting xml from invoking the method

    Because the Delete_Caller method is expecting a parameter (Caller_ID) the service asks for the Caller_ID in the form of a input form element.

    Now that we have a fully functioning Web service, all that's left is to build an ASP.NET page to consume the service. I'll do that in part 3.

    About the Author

    Paul Apostolos is Director of Internet Development for the National Roofing Contractors Association (www.nrca.net). Paul has more than 5 years experience programming and developing Web sites based on Microsoft technologies. He can be reached at paul@allpaul.com.

  • Rate This Article
    Not HelpfulMost Helpful
    1 2 3 4 5
    Other Articles
    Jul 7, 2005 - Hosting Indigo Web Services
    In the second article of his series on Indigo web services, Chris Peiris explains how to host an Indigo web service and examines the IIS, self hosting, and Windows Activation Service hosting options. He then provides step-by-step instructions and sample code for an IIS-hosted and self-hosted Indigo web service.
    [Read This Article]  [Top]
    Jun 8, 2005 - Indigo Programming Model
    In the first part of his series on Microsoft Indigo, Chris Peiris examines the basics of SOA, explains how Indigo fits into the picture and the problems it solves. He then introduces Indigo's programming model and finishes by building a sample Indigo web service using the Microsoft .Net Framework 2.0.
    [Read This Article]  [Top]
    Nov 10, 2004 - Business Intelligence with Microsoft SQL Server Reporting Services - Part 3
    Adnan Masood concludes his discussion of Microsoft SQL Server Analysis services and Microsoft SQL Server Reporting services. In the final part, he discusses Reporting Server web services and using custom code in reports.
    [Read This Article]  [Top]
    Jul 8, 2004 - Using IE's Web Service Behavior To Create Rich ASP.NET Applications
    This article explains the features of the IE Web service behavior and shows how to asynchronously communicate with an ASP.NET Web service directly from the client.
    [Read This Article]  [Top]
    Jul 6, 2004 - Using .NET and Excel 2003 To Validate E-Mails
    Calvin Luttrell shows how to validate e-mail addresses stored in Excel 2003 and provides a special function for solving that pesky problem Yahoo! mail servers cause.
    [Read This Article]  [Top]
    Jun 9, 2004 - Modifying Web Services Documentation
    This short article describes a quick and easy way to provide some security to an ASP.NET Web service by modifying its associated documentation file.
    [Read This Article]  [Top]
    Jun 2, 2004 - Kerberos Authentication with Web Services Enhancements 2.0
    Kerberos authentication is the cornerstone of Windows operating system authentication architecture. Web Services Enhancement 2.0 (WSE 2.0) extends Kerberos support to ASP.NET Web services. Chris Peiris explains the support for this new feature in WSE 2.0.
    [Read This Article]  [Top]
    Dec 15, 2003 - Realizing a Service-Oriented Architecture with .NET
    Chip Irek examines the architectural issues and component design issues of building a .NET application in a service-oriented architecture.
    [Read This Article]  [Top]
    Nov 24, 2003 - Consuming Asynchronous Web Services
    Thiru Thangarathinam shows how to use asynchronous Web services, Windows Service applications, server-based timer components and .NET XML API classes to create high-performance, scalable, and flexible applications.
    [Read This Article]  [Top]
    Nov 12, 2003 - Implementing Paging and XSLT Extensions Using XSLT in .NET - Part 2
    Part one showed how to transform XML data into HTML by using an XSL stylesheet from within a .NET application. This part explains how to make use of XSLT Extension objects and invoke a C# class method from an XSL stylesheet.
    [Read This Article]  [Top]
    Mailing List
    Want to receive email when the next article is published? Just Click Here to sign up.

    Support the Active Server Industry



    JupiterOnlineMedia

    internet.comearthweb.comDevx.commediabistro.comGraphics.com

    Search:

    Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

    Jupitermedia Corporate Info


    Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

    Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

    Solutions
    Whitepapers and eBooks
    Microsoft Article: HyperV-The Killer Feature in WinServer ‘08
    Avaya Article: How to Feed Data into the Avaya Event Processor
    Microsoft Article: Install What You Need with Win Server ‘08
    HP eBook: Putting the Green into IT
    Whitepaper: HP Integrated Citrix XenServer for HP ProLiant Servers
    Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 1
    Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 2--The Future of Concurrency
    Avaya Article: Setting Up a SIP A/S Development Environment
    IBM Article: How Cool Is Your Data Center?
    Microsoft Article: Managing Virtual Machines with Microsoft System Center
    HP eBook: Storage Networking , Part 1
    Microsoft Article: Solving Data Center Complexity with Microsoft System Center Configuration Manager 2007
    MORE WHITEPAPERS, EBOOKS, AND ARTICLES
    Webcasts
    Intel Video: Are Multi-core Processors Here to Stay?
    On-Demand Webcast: Five Virtualization Trends to Watch
    HP Video: Page Cost Calculator
    Intel Video: APIs for Parallel Programming
    HP Webcast: Storage Is Changing Fast - Be Ready or Be Left Behind
    Microsoft Silverlight Video: Creating Fading Controls with Expression Design and Expression Blend 2
    MORE WEBCASTS, PODCASTS, AND VIDEOS
    Downloads and eKits
    Sun Download: Solaris 8 Migration Assistant
    Sybase Download: SQL Anywhere Developer Edition
    Red Gate Download: SQL Backup Pro and free DBA Best Practices eBook
    Red Gate Download: SQL Compare Pro 6
    Iron Speed Designer Application Generator
    MORE DOWNLOADS, EKITS, AND FREE TRIALS
    Tutorials and Demos
    How-to-Article: Preparing for Hyper-Threading Technology and Dual Core Technology
    eTouch PDF: Conquering the Tyranny of E-Mail and Word Processors
    IBM Article: Collaborating in the High-Performance Workplace
    HP Demo: StorageWorks EVA4400
    Intel Featured Algorhythm: Intel Threading Building Blocks--The Pipeline Class
    Microsoft How-to Article: Get Going with Silverlight and Windows Live
    MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES