Saturday, May 15, 2010

WCF 1

What is the use of ServiceBehavior attribute in WCF ?
ServiceBehaviour attribute is used to specify the InstanceContextMode for the WCF Service class (This can be used to maintained a state of the service or a client too)

There are three instance Context Mode in the WCF
PerSession : This is used to create a new instance for a service and the same instance is used for all method for a particular client. (eg: State can be maintained per session by declaring a variable)
PerCall : This is used to create a new instance for every call from the client whether same client or different. (eg: No state can be maintained as every time a new instance of the service is created)
Single : This is used to create only one instance of the service and the same instance is used for all the client request. (eg: Global state can be maintained but this will be applicable for all clients)
What is a SOA Service?

SOA is Service Oriented Architecture. SOA service is the encapsulation of a high level business concept. A SOA service is composed of three parts.
1. A service class implementing the service to be provided.
2. An environment to host the service.
3. One or more endpoints to which clients will connect.
Which namespace is used to access WCF service?

Select from following answers:

   1. System.Service
   2. System.Data
   3. System.ServiceModel
   4. System.Web

What is WCF?
Windows Communication Foundation (WCF) is an SDK for developing and deploying services on Windows. WCF provides a runtime environment for services, enabling you to expose CLR types as services, and to consume other services as CLR types.

WCF is part of .NET 3.0 and requires .NET 2.0, so it can only run on systems that support it.
Difference between WCF and Web services?

Web Services
1.It Can be accessed only over HTTP
2.It works in stateless environment


WCF
WCF is flexible because its services can be hosted in different types of applications. The following lists several common scenarios for hosting WCF services:
IIS
WAS

Self-hosting
Managed Windows Service
What are the various ways of hosting a WCF service?
Self hosting the service in his own application domain. This we have already covered in the first section. The service comes in to existence when you create the object of ServiceHost class and the service closes when you call the Close of the ServiceHost class.

Host in application domain or process provided by IIS Server.

Host in Application domain and process provided by WAS (Windows Activation Service) Server.
What is three major points in WCF?

We Should remember ABC.


Address --- Specifies the location of the service which will be like http://Myserver/MyService.Clients will use this location to communicate with our service.


Binding --- Specifies how the two paries will communicate in term of transport and encoding and protocols


Contract --- Specifies the interface between client and the server.It's a simple interface with some attribute.
What is the difference WCF and Web services?

Web services can only be invoked by HTTP (traditional webservice with .asmx). While WCF Service or a WCF component can be invoked by any protocol (like http, tcp etc.) and any transport type.


Second web services are not flexible. However, WCF Services are flexible. If you make a new version of the service then you need to just expose a new end. Therefore, services are agile and which is a very practical approach looking at the current business trends.


We develop WCF as contracts, interface, operations, and data contracts. As the developer we are more focused on the business logic services and need not worry about channel stack. WCF is a unified programming API for any kind of services so we create the service and use configuration information to set up the communication mechanism like HTTP/TCP/MSMQ etc
What are various ways of hosting WCF Services?

There are three major ways of hosting a WCF services


• Self-hosting the service in his own application domain. This we have already covered in the first section. The service comes in to existence when you create the object of Service Host class and the service closes when you call the Close of the Service Host class.


• Host in application domain or process provided by IIS Server.


• Host in Application domain and process provided by WAS (Windows Activation Service) Server.
What was the code name for WCF?

The code name of WCF was Indigo .


WCF is a unification of .NET framework communication technologies which unites the following technologies:-


NET remoting

MSMQ

Web services

COM+
What are the main components of WCF?

The main components of WCF are


1. Service class

2. Hosting environment

3. End point


How to deal with operation overloading while exposing the WCF services?

By default overload operations (methods) are not supported in WSDL based operation. However by using Name property of OperationContract attribute, we can deal with operation overloading scenario.


[ServiceContract]

interface ICalculator

{

   [OperationContract(Name = "AddInt")]

   int Add(int arg1,int arg2);



   [OperationContract(Name = "AddDouble")]

   double Add(double arg1,double arg2);

}

Notice that both method name in the above interface is same (Add), however the Name property of the OperationContract is different. In this case client proxy will have two methods with different name AddInt and AddDouble.

No comments:

Post a Comment