|
Windows Communication Foundation(WCF)
|
|
1. What is WCF?
|
|
Windows Communication Foundation (WCF) is an SDK for developing and deploying services
on windows. WCF provides a runtime environment for your services, enabling you to
expose CLR types as services, and to consume other services as CLR
|
|
2. What are contract, address and bindings?
|
|
Every service is associated with an address that defines where the service is, a
binding that defines how to communicate with the service, and a contract that defines
what the service does.
|
|
3. What is endpoint in WCF?
|
|
WCF formalizes this relationship in the form of an endpoint. The endpoint is the
fusion of the address, contract and binding.
|
|
4. What are bindings?
|
|
There are multiple aspects of communication with any given service, and there are
many possible communication patterns: messages can be synchronous request/reply
or asynchronous fire-and-forget; messages can be bidirectional; messages can be
delivered immediately or queued; and the queues can be durable or volatile. There
are many possible transport protocols for the messages, such as HTTP, TCP, P2P (peer
network), IPC (names pipes), or MSMQ. To simplify these choices and make them more
manageable, WC groups together a set of such communication aspects in bindings.
A binding is merely a consistent, canned set of choices regarding the transport
protocol, message encoding, communication pattern, reliability, security, transaction
propagation, and interoperability
|
|
5. What are the main components of WCF?
|
|
The following are the main components of WCF. a) Address b) Bindings • BasicHttpBinding
• WSHttpBinding • WSDualHttpBinding • WSFederationHttpBinding • MsmqIntegrationBinding
• NetMsmqBinding • NetNamedPipeBinding • NetPeerTcpBinding • NetTcpBinding c) Contract
• Data contracts and data member • Service Contract • Fault Contract • Message Contract
d) End Point e) Deploy • Windows application • Console application • Windows service
• IIS • WAS (Windows Activation Service), comes with IIS 7.0 • Windows presentation
foundation
|
|
6. What is Service contract?
|
|
Describes which operations the client can perform on the service.
|
|
7. What is Data contract?
|
|
Defines which data types are passed to and from the service. WCF defines implicit
contracts for built-in types such as int and string, but you can easily define explicit
opt-in data contracts for custom types.
|
|
8. What is Operation contract?
|
|
You must explicitly indicate to WCF which methods to expose as part of the WCF contract
using the OperationContract attribute. You can apply the OperationContract attribute
on methods, but not on properties, indexers, or events, which are CLR concepts.
|
|
9. What are the various ways of hosting a WCF service?
|
|
A WCF service can be hosted via one of the following ways. Windows application Console
application Windows service: WCF service can be controlled by the Service control
manager IIS: Can be hosted in IIS provided the service exposes at least one HTTP
end point WAS (Windows Activation Service—comes with IIS 7.0): Removes dependability
upon HTTP Windows presentation foundation
|
|
10. What is the difference between WCF and Web service?
|
|
WCF "web services" are part of a much broader spectrum of remote communication enabled
through WCF. You will get a much higher degree of flexibility and portability doing
things in WCF than through traditional ASMX because WCF is designed, from the ground
up, to summarize all of the different distributed programming infrastructures offered
by Microsoft. An endpoint in WCF can be communicated with just as easily over SOAP/XML
as it can over TCP/binary and to change this medium is simply a configuration file
change. In theory this reduces the amount of new code needed when porting or changing
business needs, targets, etc. ASMX is older than WCF, and anything ASMX can do so
can WCF (and more). Basically you can see WCF as trying to logically group together
all the different ways of getting two apps to communicate in the world of Microsoft;
ASMX was just one of these many ways and so is now grouped under the WCF umbrella
of capabilities
|
|
11. Can you explain transactions in WCF?
|
|
Transactions are the key to building robust, high-quality service-oriented applications.
WCF provides simple, declarative transaction support for service developers, enabling
you to configure parameters such as enlistment and voting, all outside the scope
of your service. In addition, WCF allows client applications to create transactions
and to propagate transactions across service boundaries. A transaction is a set
of potentially complex operations in which the failure of any single operation causes
the entire set to fail, as one atomic operation. If the transaction is executed
successfully, and managed to transfer the system from the consistent state A to
the consistent state B, it is called a committed transaction. If the transaction
encountered any error during its execution and rolled back all the intermediate
steps that have already succeeded, it is called an aborted transaction. If the transaction
failed to either commit or abort, it is called an in-doubt transaction.
|
|
12. Can you explain duplex contracts in WCF?
|
|
A duplex service contract is a message exchange pattern in which both endpoints
can send messages to the other independently. A duplex service, therefore, can send
messages back to the client endpoint, providing event-like behavior. Duplex communication
occurs when a client connects to a service and provides the service with a channel
on which the service can send messages back to the client.
|
|
13. What different transaction isolation levels provided in WCF?
|
|
In general, the more isolated the transaction, the more consistent their results
are. The following are the isolation levels supported in WCF. o Unspecified o ReadUncommitted
o ReadCommitted o RepeatableRead o Serializable o Chaos o Sanpshot
|
|
14. Can we do Asynchronous post back using AJAX/JSON in WCF?
|
|
Yes.
|
|
15. What is ABC in WCF
|
|
Contract (What, C): Contract is an agreement between two or more parties. It defines
the protocol how client should communicate with your service. Technically, it describes
parameters and return values for a method. Address (Where, A): An Address indicates
where we can find this service. Address is a URL, which points to the location of
the service. Binding (How, B): Bindings determine how this end can be accessed.
It determines how communications is done. For instance, you expose your service,
which can be accessed using SOAP over HTTP or BINARY over TCP. So for each of these
communications medium two bindings will be created. Note: for more info and examples
browse the following link http://msdn.microsoft.com/en-us/netframework/bb499684.aspx
|