<%@ Page %>

Developing A Newsletter Subscription Web Service


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, trainer, author, and meditation teacher. He has been programming, meditating, and teaching for 25+ years. He conducts instructor-led online training courses in ASP.NET family of technologies for individuals and small groups. He is a published author and has authored or co-authored books for Apress and Wrox press. Having embraced the Yoga way of life he also teaches Ajapa Yoga to interested individuals. To know more about him click here.

    Get connected : Facebook  Twitter  LinkedIn  YouTube

    Posted On : 29 March 2002

    Tags : ASP.NET Web Services