<%@ Page %>
Developing A Newsletter Subscription Web Service
Introduction
Web services offer their functionality over the web via standards like HTTP and
XML. There are many models suggested for implementing the business functionality
via web services. One of them is subscription based services. Such services
allow the users to subscribe or unsubscribe to the service as per their
requirement. This sample application shows you how to develop a newsletter
subscription service in ASP.NET. The development language used is C# but you can
easily port it on VB.NET. All the files needed to run the application are included with the download.
The Web Service project
The web service contains following web methods:
- Subscribe: Allows users to subscribe to the various newsletters
- Unsubscribe: Allows users to unsubscribe from any newsletter
- GetSubscribtions : Get subscriptions of a user
- GetNewsletterDetails : Get details about available newsletters
- SendNewsletters : Sends newsletters via email
- IsValid : Checks whether a user id and password combination is valid.
Note that the web service uses email address to uniquely identify
the users.
In addition to the above web methods it also contains following supporting
methods:
- IsExist : Chekcs whether the user already exists in the database
- ExecuteSQL : Used to fire action queries
- GetDataSet : Used to get a DataSet populated with specified records.
Client for the web service
Even though your web service is great in functionality unless it is supplemented with a user friendly interface it is of no use. The second sample included in the download shows how to create a simple yet user-friendly client for our web service. The interface consists of a login page where in user specifies his email and password. Based on the details he is presented with a plain list of all newsletters or a list of newsletters with his subscriptions marked. He can then choose whatever newsletters he wants to receive.
How to run/test the applications
Create a web service project in C# using VS.NET
Unzip supplied .asmx and corresponding .cs file to the project folder
Add them to the project
Modify the connection string to match your database
Compile the project
Create a web application in C# using VS.NET
Unzip supplied .aspx and corresponding .cs file to the project folder
Add them to the project
Add web reference to the web service
Compile and run the project
Bipin Joshi is an independent software consultant and trainer by profession specializing in Microsoft web development technologies. Having embraced the Yoga way of life he is also a meditation teacher and spiritual guide to his students. He is a prolific author and writes regularly about software development and yoga on his websites. He is programming, meditating, writing, and teaching for over 27 years. To know more about his ASP.NET online courses go
here. More details about his Ajapa Japa and Shambhavi Mudra online course are available
here.