Raghavan's Blog: November 2008

Saturday, November 15, 2008

WCF For Starters

Folks,
Here are few points about WCF
To create a wcf service
1) Create a Service Contract [ Implement ServiceContract from Service Model namespace]. Basicaly its creating an Interface through which tells what type of operations the web service can perform. Also add [OperationContract] attribute to all the interface methods.
2) If you have any specific data to be passed, create a Data contract by adding DataContract attribute.
3) Create your Service Implementation. Make sure you mention the service behaviour, whether it is a singleton/singlecall.

Thats it, we are ready with the service.
Now its now in creating your end-points. You can have the basic http binding, TCP binding, and named pipes(new in IIS-7)
A single WCF service can be exposed through different end points.

There is a built in WCF Client which finds the hosted services at different end points. The WCF Client by itself uses the IMetaDataExchange service.


Fix for a intermediate problem you face in Windows Vista with low priveleges :

When you change the default port from :8731 to any other port, you would get error like below :
HTTP could not register URL http://+:8000/. Your process does not have access rights to
this namespace (see http://go.microsoft.com/fwlink/?LinkId=70353 for details).

To get fix for that you have start cmd and run as administrator(Type cmd and press CTRL+SHIFT+ENTER) to run Command prompt as administrator.

Use netsh http show urlacl to view list of ports that are usable by \.
Now to add your custom port, you have do like below :
netsh http add urlacl url=http://+:8000/ user=MYMACHINE\UserName
This resolves the issue :-)

Next is creating your Test project for consuming your wcf service. In thenext post.

Any issues, pls feel free to give a call or drop an email :
Sriraghavan
Office : sriraghavan_venkataraman@ml.com
Personal : raghavan_17@yahoo.com
Phone : +91 9962456279