MCSD Windows Communication Foundation (WCF) 1 — Questions and Answers
Question 1: Which three core components form the ABC of WCF service configuration?
- Address, Binding, Contract (Correct answer)
- Authentication, Binding, Connection
- Address, Behavior, Configuration
- Attribute, Binding, Channel
Correct answer: Address, Binding, Contract
WCF services are defined by Address (where), Binding (how), and Contract (what), collectively called the ABCs of WCF.
Question 2: Which attribute is used to mark an interface as a WCF service contract?
- [ServiceBehavior]
- [OperationContract]
- [ServiceContract] (Correct answer)
- [DataContract]
Correct answer: [ServiceContract]
[ServiceContract] is applied to an interface or class to define it as a WCF service contract that clients can call.
Question 3: Which WCF binding is optimized for cross-machine communication over HTTP and interoperability with non-.NET clients?
- NetTcpBinding
- BasicHttpBinding (Correct answer)
- NetNamedPipeBinding
- WSDualHttpBinding
Correct answer: BasicHttpBinding
BasicHttpBinding uses SOAP 1.1 over HTTP, making it the most interoperable binding for non-.NET clients.
Question 4: Which WCF binding provides the highest performance for same-machine inter-process communication?
- BasicHttpBinding
- WSHttpBinding
- NetTcpBinding
- NetNamedPipeBinding (Correct answer)
Correct answer: NetNamedPipeBinding
NetNamedPipeBinding uses Windows named pipes for communication within the same machine, providing the highest performance for local IPC.
Question 5: What does the [OperationContract] attribute designate in a WCF service?
- A property exposed in the service metadata
- A method that is part of the service contract (Correct answer)
- A data structure transferred between client and service
- A behavior applied to the service host
Correct answer: A method that is part of the service contract
[OperationContract] marks a method on a [ServiceContract] interface as an operation that clients can invoke remotely.
Question 6: Which class is used to self-host a WCF service in a .NET application?
- WebServiceHost
- ServiceHost (Correct answer)
- ChannelFactory
- ServiceEndpoint
Correct answer: ServiceHost
ServiceHost is used to host a WCF service within any managed process including console apps, Windows services, or WPF applications.
Question 7: Which WCF message exchange pattern allows the service to send messages back to the client without the client initiating a request?
- Request-Reply
- One-Way
- Duplex (Correct answer)
- Streaming
Correct answer: Duplex
The Duplex message exchange pattern establishes a two-way channel, allowing the service to call back to the client via a callback contract.
Which three core components form the ABC of WCF service configuration?