M G Vinod Kumar\’s Technology Blog

April 25, 2006

HelloWorld WebService in Visual Express Editions

Filed under: .NET, Web Services — mgvinod @ 4:52 pm

Implementing and consuming a webservices using Visual Express editions is quite easy to do. You will need both Visual Web Developer Express edition and Visual C# edition installed. I won't delve into the details of the WebServices, just a quick start to get you going.

Creating a HelloWorld WebService

1. Using Visual Web Developer Express, create a new ASP.NET Web Service by File -> New Web Site…. Let us give a name of HelloWorldWebService and click OK.

2. By default, it should have created all files that are required including HelloWorld Method already implemented in Service.cs file. Open the file Service.asmx and you will see just one line of code.

3. Select the solution in the Solution Explorer and in the Properties window, set Use dynamic ports to False. If you wish to change the Port number, you may change it now. For me, it is showing 3697.

4. Press Ctrl+F5. This should build the solution and deploy the webservice using local development IIS that comes along with the express edition.

If you select the HelloWorld link, it should allow you to test the web service by click the Invoke button. It should open a web browser window with result as given below.

<?xml version="1.0" encoding="utf-8" ?>

<string xmlns="http://tempuri.org/">Hello World</string>

Leave the IIS running. You should be having a small icon in your system tray indicating that. Now, let us look at how to write a client to use this Web Service.

Consuming the HelloWorld WebService

1. Start Visual C# Express Edition. Create a new Console Application. (You may use window application also as your client application.) Let us name it as HelloWorldWebServiceClient.

2. Now Add Web Reference… by right clicking on the References in Solution Explorer. Enter the url


It should display the available opertions, in our case, it is HelloWorld. Click Add Reference. This should add localhost under the Web References folder in Solution Explorer.

Note: Ensure that the right Port number is mentioned.

3. Open the Program.cs and add the following code in the Main method.

localhost.Service service = new localhost.Service();

Console.WriteLine("Message Received: {0}", service.HelloWorld());

4. Press Ctrl+F5. This should build the solution and a message like this should be displayed in your console.

Message Received: Hello World

That's it.

April 24, 2006

Marker Pattern aka Marker Interface Pattern

Filed under: .NET, Pattern — mgvinod @ 10:22 am

The Marker Pattern is popularly known as Marker Interface Pattern. I removed the Interface since this pattern can be implemented in two ways. Let us consider each of the ways.

1. Using an interface

First an interface is created as given below.

interface ITransactionAware{


Then, the class implements the interface.


class ClassWithMarkerInterface : ITransactionAware{


Using reflection, class can be checked to whether it implements the interface or not. Based on that result, any required action can be taken.


ClassWithMarkerInterface clsInterface = new ClassWithMarkerInterface();

if (clsInterface is ITransactionAware){

//start transaction



2. Using an attribute

Instead of an interface, an attribute is used.

class TransactionAttribute : System.Attribute{


The class is then marked with the above attribute.



class ClassWithAttributeMarker {


The code to check for attribute is little more verbose than using the interface.


ClassWithAttributeMarker clsAttribute = new ClassWithAttributeMarker();

if (clsAttribute.GetType().IsDefined(typeof(TransactionAttribute),false)){

//start transaction



As you can see, using an attribute is slower than the normal interface. Purists would argue that an attribute should be used, but if performance is your top criteria then interfaces are the way.




Dispose pattern in depth

Filed under: .NET, Design Guidelines, Pattern — mgvinod @ 9:41 am

Dsipose pattern is one of the most often used and mentioned patterns within .NET world. If you are interested in knowing the details, you should read this from the source.

Enum Design Guidelines

Filed under: .NET, Design Guidelines — mgvinod @ 9:37 am

If you think there is not too much to think about while designing Enums, well, think again! Have a look at this blog entry  .

April 21, 2006

Microsoft Visual Express is Free Now

Filed under: .NET — mgvinod @ 8:43 am

Microsoft has just announced that Visual Express editions are free. See link http://www.microsoft.com/presspass/press/2006/apr06/04-19VSExpressFreePR.mspx&nbsp;

Its everybody's guess that Microsoft would want more developers to start using their technologies rather than Java, which is also free. It will be interesting to find out how much support will be provided for these editions. You will often hear them say, this feature is available in Enterprise edition and not in Express edition. I guess, nothing comes FREE!!!

Create a free website or blog at WordPress.com.