What is WCF and what does WCF stand for?
WCF stands for Windows Communication Foundation is a framework for developing applications that are service-oriented. They are used for creating an application that is interoperable and distributed. This means that these can be executed on multiple systems connected through the same network. These apps can be connected to other applications developed in a different platform.
Which specifications does WCF follow?
WCF follows the specifications given below:
- Messaging (WS Addressing)
- Reliability (WS Reliable Messaging)
- Security (WS Secure Conversion, WS Security, WS Trust)
- Transaction (WS Atomic Transaction and WS Coordination)
- Metadata (WS Metadata exchange and WS Policy)
What are the main components of WCF?
The main components of WCF are:
- Service class – It is a class that implements a CLR based language.
- Hosting environment – It is an environment that is used for executing a service.
- Endpoint – A medium through which the client and the service communicate with each other.
How to create WCF service?
The steps to create a WCF service are given below:
- Launch Visual Studio and right-click on the Project.
- Select add an item and then from the 'Web tab' select WCF Service.
- Expose the Endpoints and Metadata for the service. For this, inside the Web.config file create the endpoint and add the metadata endpoint.
- Next, open the service file and provide the implementation code in the Service Contract.
- Consume the WCF Service.
What is an endpoint in WCF?
A WCF service program has a collection of endpoints. All communications with WCF is possible through the endpoints that provide the users with the access to the functionality of the service.
They have the following components:
- An address indicating the endpoint’s location.
- A binding that tells the client the way to communicate with that endpoint.
- The existing operations are present inside the contract.
- Behaviors mentioning the implementation details of the endpoint.
What is a service contract in WCF?
A service contract in WCF is basically an agreement between the client and the service. It specifies the functions that can be called by the client and the operations they are offered. It is also used to define the exchange patterns for messages while sharing them. Contracts can be divided into two parts namely structural and behavioural.
How to host WCF service in IIS?
A service can be hosted in IIS through the following steps:
- Launch Visual Studio and right-click on the Project.
- Select add Item and then from the 'Web tab' select WCF Service.
- Add a reference of the Service to the IIS Host project.
- Change the value of the Service parameter to ‘Service="MathService.MathService". Delete the ‘CodeBehind="~/App_Code/Service.cs"
- Make necessary changes in the Web.config file.
- After opening the IIS project go to the Server name and then select 'Go to the site'.
- Right-click on the site and select Add Website.
- Provide a physical path, name and port for the site.
- The site will be added to the IIS.
What is metadata in WCF?
Metadata in WCF is used to describe the different features of the service. This data is presented to the client to better analyze the communication with the service. It is enabled through the ServiceMetadata node.
What is WCF RIA Services?
The WCF RIA (Rich Internet Application) services are a framework that is used along with Silverlight 4 to reduce the complexity of developing a business application. It helps the developers to solve the problems of coordinating the code between the presentation and middle layer. It supports validation from the client side by providing service code that will present on the client-side.
What are different bindings supported by WCF?
The different bindings supported by WCF are:
- Basic Http Binding
- Net TCP Binding
- Net Named Pipe Binding
- WS Http Binding
- WS Dual Http Binding
- Net Msmq Binding
- Net Peer TCP Binding
- WS Federation Http Binding
- Msmq Integration Binding
What is a proxy in WCF?
A proxy in WCF is a class that is used to interact with the client application. It is a CLR class that is used to expose a CLR interface representing the Service Contract in the Service. Methods can be added to the proxy class to enhance the connection. It removes the requirement for creating a client’s configuration setting as all the proxy class provides all the configuration information.
Which transport schema is supported by WCF?
WCF supports the following transport schemas:
- Peer Network
- IPC (Inter-Process Communication using named pipes)
How to debug WCF service?
The steps to debug a WCF service are given below:
- Attach the debugger to the process where the WCF service is executing.
- If it is in IIS, the w3p.exe process has to be attached.
- The name of the exe file has to be attached if it is a windows service or a standalone application.
- Open the debugger menu inside Visual Studio, click on the option Attach to process. Open the required code and set a breakpoint.
- Call the WCF service
What are message exchange patterns in WCF?
The message exchange patterns in WCF are used to set up a communication channel between the service and the client. It is required when the function needs to be called without waiting for the response so that the function call does not get blocked. It helps in calling the functions faster.
Three types of message exchange patterns are supported by WCF:
- One way
What is interoperability in WCF?
Interoperability in WCF means that the applications can be connected to other applications developed in a different platform. Any client can consume it, be it .Net or Java.
Interoperability between WCF and ASP.NET Web Services can be fulfilled if services created through both technologies follow the WS-I Basic Profile 1.1 specifications.
What is web HTTP binding in WCF?
The web HTTP binding is a binding element which is used to manage the endpoints for WCF for responding to HTTP requests. As it supports WS-*, the data is not sent in plain text as the security feature is enabled. It is a reliable messaging functionality WS-* specifications.
What is throttling in WCF?
At the application level, the number of sessions or instances is limited by throttling. This provides certain properties for controlling the instances in a WCF service.
In this process, the concurrent sessions and calls have to be mentioned. The instance provides a way for the WCF service and the client to communicate.
What are different transaction isolation levels provided in WCF?
The different transaction isolation levels provided in WCF are:
- Read Uncommitted
- Repeatable Read
- Read Committed
How to maintain security in WCF?
Security in WCF is maintained through its key features:
Two other approaches can be adopted:
- Transfer security mode ensures a secure communication channel between the server and the client.
- Message security mode ensures secure communication by encrypting the message through an algorithm.
How to hide methods in WCF?
The service methods in WCF can be hidden through altering the values of the Name Attribute of Operation Contract. This is done so that the client does not see the method name created on the server-side.