Posts

Showing posts from June, 2011

WCF Interview Question

Data Contracts, is used to define Required or NonRequired data members. It can be done with a property named IsRequired on DataMember attribute. [DataContract] public class test { [DataMember(IsRequired=true)] public string NameIsMust; [DataMember(IsRequired=false)] public string Phone; } Can we overload methods in WCF Service or Web Service? Yes for a WCF Service use the Name property of OperationContractAttribute class example: [ServiceContract] interface ddd { [OperationContract(Name = "one")] int calc(int a,int b); [OperationContract(Name = "two")] double calc(double a,double b); } 1)For a Web Service use the MessageName property of WebMethodAttribute class 2)Please comment the following line in the .cs file of the Web Service //[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [WebMethod] public string HelloWorld(string a) { return "Hello"+" "+a; } [WebMethod(MessageName="second...

ASP.NET URL Rewriting with HttpHandler

Most of the time when we start learning something or doing something we get the first question that how does it helps? Or where I can use in the real world? Same thing goes in this technique as well. What are URL rewriting first of all then what is routing engine? Let us see some real issues in our code. A. Case 1 One day you had a URL book marked as Http://abc.com/main/1.aspx. But now it is moved to Http://xyz.com/main/1.aspx, will it work now, no. But as a web site developer or architect how you will manages these kinds of broken links in web sites. B. Case 2 Suppose we have two servers where each server has hosted with 50 pages. But all the links have to be made available for both web sites. How do we handle this situation? C. Case 3 A website restructuring caused all of the Web pages in the /Admin/ directory to be moved to a /finance/Admin/ directory, you would want to use URL rewriting to check if a Web request was intended for a file in the /Admin/ directory. The reques...

WCF Overview

Image
WCF is a .NET platform for developing services .Service is any functionality that can be consumed by the outside world. A service defines well defined communication protocols to communicate with it. A service can be located anywhere , it could be on local machine on the intranet or even internet.A client consumes the functionality exposed by the service.A service can be anything it can be an independent application like asp.net or it can be another service. Client and Service communicate with each other by sending messages. SOAP Message SOAP Message Client HTTP/TCP /MSMQ HTTP/TCP/MSMQ Server Figure: Basic Client Server Communication Since the functionality of the service is hidden to the outside world. Service exposes metadata that client uses to communicate with the service. Metadata can be in any technology neutral format like wsdl. Client always uses proxy to communicate with the service irrespective of where service is located. In WCF every service has endpoints and the cli...