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")]
public string HelloWorld()
{
return "Hello second";
}

Advantages of Hosting WCF in IIS?

1. Provides process activation and recycling ability thereby increasing reliability
2. It is a simplified way of deployment and development of hosted services.
3. Hosting WCF services in IIS can take advantage of scalability and density features of ASP.NET


What are the different WCF binding available?


BasicHttpBinding
• WSHttpBinding
• WSDualHttpBinding
• WSFederationHttpBinding
• NetTcpBinding
• NetNamedPipeBinding
• NetMsmqBinding
• NetPeerTcpBinding
• MsmqIntegrationBinding

What are the different platforms where we can host WCF service ?

WCF Services can be hosted on following platforms

1. WAS(Windows Activation Service)

2. Self Hosting

3. IIS

What is Address Header in WCF?

Address Header contains the information which is sent with every request, it can be used by either end point service or any intermediate device for determining any routing logic or processing logic.

WCF provides AddressHeader class for this purpose.

Example :

AddressHeader addressHeader= AddressHeader.CreateAddressHeader("Name of the header", "Information included in header ");


Once the AddressHeader instance is created, it can be associated with end point instance as follows :
EndpointAddress endpoint = new EndpointAddress(new Uri("http://myserver/myservice"), addressHeader);


In WCF, following bindings supports the reliable session

1. wsHttpBinding
2. wsDualHttpBinding
3. wsFederationHttpBinding
4. netTcpBinding

WAS (Windows Activation Service) is a component of IIS 7.0. Following are few advantages :

1. We are not only limited to HTTP protocol. We can also use supported protocols like TCP, named pipes and MSMQ

2. No need to completely install IIS. We can only install WAS component and keep away the WebServer.

1. Service host factory is the mechanism by which we can create the instances of service host dynamically as the request comes in.

2. This is useful when we need to implement the event handlers for opening and closing the service.

3. WCF provides ServiceFactory class for this purpose.


Following bindings supports the streaming in WCF:

1. basicHttpBinding
2. netTcpBinding
3. netNamedPipeBinding

Comments

Popular posts from this blog

What You Can Do With LINQ to SQL

JavaScript Interview Questions

WCF Overview