A WCF service can be self-hosting using a console application or Windows Forms applications. Hosting a WCF service in any managed .Net application is called self-hosting. Now the following is the procedure for creating a WCF service and hosting it in a console application. Hosting Environment Requirements:
* Availability: When do you want to be able to reach your service?
* Reliability: What happens when your service somehow breaks? How does this affect other consumers?
* Manageability: Do you need easy access to information about what is happening on the host where WCF services live?
* Versioning: Do you need to support older versions of the service? Do you know who is consuming your services?
* Deployment: What is your deployment model? Are you installing through the Microsoft * Installer process and Visual Studio deployment packages, or is xcopy sufficient?
*State: Are your services stateless? Do you need sessions?
Posted Date:- 2021-09-20 00:06:37
Fault Contract provides documented view for error accorded in the service to client. This help as to easy identity the what error has occurred, and where. By default when we throw any exception from service, it will not reach the client side. The less the client knows about what happened on the server side, the more dissociated the interaction will be, this phenomenon (not allowing the actual cause of error to reach client) is known as error masking. By default all exceptions thrown on the service side always reach the client as FaultException, as by having all service exceptions indistinguishable from one another, WCF decouples the client from service.
Posted Date:- 2021-09-20 00:04:25
-A transaction is a logical unit that defines multiple activities in WCF either pass or fails. The two common types of transactions are – Atomic and Long Running. Two phases of transactions are Prepare Phase and the Commit Phase.
Posted Date:- 2021-09-20 00:03:06
To a particular service instance WCF binds an incoming message request, so the available modes are
* Per Call: This instance is created for each call, efficient in terms of memory but need to maintain session
* Per Session: For a complete session of a user instance are created
* Single: One instance is created which is shared among all the users and shared among all. In terms of memory it is least efficient.
Posted Date:- 2021-09-20 00:02:13
Per session instance mode creates a logical session between service and client and it will be maintained till the end of the session. When client requests from service the session will be created and it is dedicated to the instance for that client and it will be going to the end when client session ends.
Posted Date:- 2021-09-20 00:01:20
When a request has made to service, it creates a new instance of service for each method call and this will be disposed of once the response goes to the client. This whole process is known as per call instance mode.
Posted Date:- 2021-09-20 00:00:45
Services often use a technique called impersonation to restrict client access to a service domain's resources. In WCF, impersonation is disabled by default, and services are accessed via the process identity of the WCF service.
Posted Date:- 2021-09-20 00:00:00
When you have a large amount of data to transfer, the streaming transfer mode in WCF is a feasible alternative to the default behavior of buffering and processing messages in memory in their entirety.
In WCF any receiving message is delivered only once the entire message has been received. What I mean here is that first message is buffered at the receiving side and once it is fully received it gets delivered to the receiving end. The main problem with this approach is that the receiver end is unresponsive while the message is getting buffered. So default way of message handling in WCF is ok for small size messages but for the large size messages, this approach is not good. So to overcome this problem Streaming in WCF come into action.
Posted Date:- 2021-09-19 23:59:25
The WCF programming model separates endpoint operations (as expressed in a service contract) from the transport mechanism that connects two endpoints. This gives you the flexibility to decide how to expose your services to the network. The transport layer is at the lowest level of the channel stack. A transport sends or receives the serialized form of a message to or from another application. The main transports used in Windows Communication Foundation (WCF) are:
HTTP,
HTTPS,
TCP
named pipes.
Posted Date:- 2021-09-19 23:58:03
For troubleshooting unexpected problems in applications, exception handling is essential. Exception handling is a feature of object programming languages and it is an error that occurs during execution. In WCF, there are three ways to handle exceptions:
returnUnknownExceptionsAsFaults: Debugging Mode
FaultException: Best Option
IErrorHandler: Only when Fault cannot handle the exception
Posted Date:- 2021-09-19 23:56:44
WCF Data Services is basically a platform for what Microsoft calls Data Services. Tabular data can be exposed as a set of REST APIs, allowing standard HTTP verbs such as GET, POST, PUT, and DELETE to be used. The OData protocol is used by WCF Data Services for addressing and updating resources.
Posted Date:- 2021-09-19 23:55:14
MEP (Message Exchange Pattern) is a way of communicating between clients and servers in WCF. MEP is one of the greatest features of WCF. The three types of MEPs supported by WCF are as follows:
Request-Reply: Request-Reply is WCF's default communication pattern.
One-way: Using this pattern means you don't expect to receive a response back from the service after it performs a certain operation.
Duplex: Duplex is a two-way communication way. The duplex MEP is applicable when the client initiates a long-running process with the service and the service requires notification.
Posted Date:- 2021-09-19 23:53:19
In WCF, the transport security mechanisms are dependent on the binding and transport that is used. It ensures the message passes securely from the client to the service over a transport medium. This point-to-point security is established using SSL (Secure Socket Layer). Integrity, privacy, and authentication are the goals of transport-level security.
Posted Date:- 2021-09-19 23:52:37
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.
Posted Date:- 2021-09-19 23:51:41
Throttling is derived from the keyword throughput, which means work that is performed at specific intervals of time. We can limit the number of instances or sessions created at the application level using the properties like maxConcurrentCalls, maxConcurrentInstances, and maxConcurrentSessions provided by WCF throttling. Performance is boosted by using it.
Posted Date:- 2021-09-19 23:43:33
Different address format of WCF include:
1. HTTP Address Format: http:// localhost:
2. TCP Address Format: net.tcp://localhost:
3. MSMQ Address Format: net.msmq://localhost:
Posted Date:- 2021-09-19 23:41:14
To access WCF service, “System.ServiceModel” is used. It provides classes that relate to service models. The namespace contains the types necessary for building WCF services and client applications.
Posted Date:- 2021-09-19 23:27:22
WCF uses an Instance Management approach to bind a set of messages (client requests) to a set of service instances. The need for Instance Management is crucial since the demands of applications vary too much in terms of scalability, throughput, transactions, queues, and performance. Therefore, one solution does not fit all applications.
Posted Date:- 2021-09-19 23:26:36
There are two different ways to call a WCF service or create a WCF client:
1 . WCF Proxy
2 . Channel factory
Posted Date:- 2021-09-19 23:26:03
An SOA (Service-oriented architecture) is an architecture style that enables different applications to be organized as Services. In essence, it determines how communication is possible between two computing entities and how one entity performs functions on behalf of another entity. Rather than being a specific technology or language, SOA is a way to design systems. The purpose of this architecture model is to enhance an enterprise's efficiency, agility, and productivity.
Posted Date:- 2021-09-19 23:24:55
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.
Posted Date:- 2021-09-19 23:24:22
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.
Posted Date:- 2021-09-19 23:23:50
Three different types of transaction managers supported by WCF include:
<> Light Weight
<> WS- Atomic Transaction
<> OLE Transaction
Posted Date:- 2021-09-19 23:22:26
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+
Posted Date:- 2021-09-19 23:21:32
A transaction is a logical unit that defines multiple activities in WCF either pass or fails. The two common types of transactions are – Atomic and Long Running. Two phases of transactions are Prepare Phase and the Commit Phase.
Posted Date:- 2021-09-19 23:20:50
The Binding will explain to you how will you communicate with the service. There are plenty of protocols to facilitate communication in WCF. These are HTTP, TCP, MSMQ, etc. The characteristics of binding are Protocol, Encoding, or Transport, etc.
Posted Date:- 2021-09-19 23:20:21
If you are not sure where to send messages then addresses play an important role here. This is a Uniform Resource Locator (URI) that will identify the location of the receiver. It is similar to the network address and highly useful to send or receive messages. It can be divided into four parts – Scheme, Machine, Port, and path. Each address is unique in itself and finds out the location of the receiver accurately without any error. There are plenty of protocols are used to exchange messages in WCF. These are HTTP, TCP, MSMQ, etc.
Posted Date:- 2021-09-19 23:19:47
The objective of the message contract in WCF is to define the structure for the message and how can you perform the serialization. By default, it will take care of SOAP messages based on service requirements. Here is given the general syntax for message contract in compact form – [code] [MessageContract] Public Class AutherRequest { Public String AutherId; } [/code]
Posted Date:- 2021-09-19 23:19:09
Sometimes complete control over the structure of a SOAP message is just as important as control over its contents (that defined by Data Contracts). This is especially true when interoperability is important or to specifically control security issues at the level of the message or message part. In these cases, you can create a message contract that enables you to specify the structure of the precise SOAP message required.
Posted Date:- 2021-09-19 23:18:30
This is the frequently asked WCF Interview Questions in an interview. When the object instance changes into a portable and visible format, that process is known a Serialization and data serialization is also known as Datacontractserilizer.
Posted Date:- 2021-09-19 23:18:01
WCF application consists of 3 components:
WCF Service
WCF Service Host
WCF service client
Posted Date:- 2021-09-19 23:17:04
Using WCF tracing, you can diagnose data, fault messages, and analyze them. Tracing offers better insight into the application's behavior and flows than debugging. It gives you a detailed account of all application components including faults, code exceptions, system events, and operation calls. By default, WCF tracing is not enabled, therefore it must be enabled by configuring it with the switch value and tracelistener.
Posted Date:- 2021-09-19 23:15:36
WCF proxy classes enable client applications to communicate with services by sending and receiving messages. Communication involves exchanging messages in the form of requests and responses. This will include details such as the Service Path, Protocol Details, etc.
Posted Date:- 2021-09-19 23:15:05
Endpoints generally provide WCF with instructions on how to construct communication channels at runtime to send and receive messages. It provides the necessary configuration to set up the communication and to create the complete WCF service application.
Endpoint consist of the following three elements:
Address: The address identifies the endpoint and tells potential customers where to find it. In the WCF object model, it is represented by the EndpointAddress class.
Binding: Bindings describe how clients can communicate with an endpoint. Furthermore, it specifies what transport protocol to use, which message format to use, and which web service protocols to use for a particular endpoint.
Contract: Contracts specify what functionality the endpoint provides the client. Furthermore, it provides information about the structure of the various message contents that are intended to be used by the various operations that are exposed to specific endpoints.
Posted Date:- 2021-09-19 23:12:57
The following are the different methods of hosting WCF services:
In WCF, concurrency issues can occur when multiple threads access the same resource simultaneously. One request can be handled at a time by the WCF service. With WCF concurrency management, you can control multiple threads within an InstanceContext at any given time using System.ServiceModel.ServiceBehaviorAttribute. It also helps you to configure the number of service instances that can serve multiple concurrent requests.
WCF 4.0 supports three types of concurrency:
* Single Concurrency Mode: In this scenario, the WCF service object is accessible to one request at a time. As a result, only one request can be processed at any given time.
* Multiple Concurrency Mode: In this scenario, the WCF service object can handle multiple requests at any given time in this scenario. In simple words, multiple threads are spawned on the WCF server object to processing requests at the same time.
* Reentrant Concurrency Mode: As described here, the WCF service object is accessible to only one request thread, but this thread may exit the WCF service to invoke another WCF service or may utilize a callback to invoke a WCF client and then reenter without deadlock
Posted Date:- 2021-09-19 23:11:43
WCF 3.5 provides explicit support for RESTful communication using a new binding named WebHttpBinding.
The below code shows how to expose a RESTful service
[ServiceContract]
interface IStock
{
[OperationContract]
[WebGet]
int GetStock(string StockId);
}
By adding the WebGet Attribute, we can define a service as REST based service that can be accessible using HTTP GET operation.
Posted Date:- 2021-09-19 23:08:08
Every service must have Address that defines where the service resides, Contract that defines what the service does and a Binding that defines how to communicate with the service. In WCF the relationship between Address, Contract and Binding is called Endpoint.
The Endpoint is the fusion of Address, Contract and Binding.
Posted Date:- 2021-09-19 23:07:39
A data contract is a formal agreement between the server and the client between whom data is exchanged securely. It could be defined either implicitly or explicitly based on the requirement. It will define the format, structure, and type of data to be exchanged between parties. It will define the process of how can data be serialized or deserialized. This is a versioning system that helps to manage changes for structural data. [code] [DataContract] Public class cuboidInfo { } [/code] Here, in the example, we have given the general syntax for the data contract. It will provide complete data abstraction at a new level like never before.
Posted Date:- 2021-09-19 23:07:21
The main objective of defining contracts is to make agree with both client and server for the same operations, structures, data types, etc. This is important to establish secure communication between the two. This is a formal agreement to define the platform neutrality and standards as well as what is done by the services. Here is given most common types of contracts that are frequently used within WCF technology.
<> Service Contract
<> Operation Contract
<> Data Contract
<> Message Contract
<> Fault Contract
Posted Date:- 2021-09-19 23:07:03
The Service Contract is a collective mechanism where the capabilities and requirements of service are specified for its consumers. It will explain the list of operations that will be performed by the service when it is executed. It will define the data types, protocols, and operation locations for the service. Defining a service contract for WCF is not easy but developers should have the right skills and experience to complete this task.
Posted Date:- 2021-09-19 23:06:22
SOA means a service-oriented architecture that helps to organize apps as Services. This is a group of methods that define the business logic and helps to connect with DB and other services quickly. Take an example of the restaurant where you go and order food. Your order will go from the counter to the kitchen and it is served on your table finally.
The benefits of SOA architecture - Independent, Self-contained, self-explanatory, etc. SOA Architecture – It consists of four key abstractions – an application front end, a service repository, a service bus, a service, etc. Web services are not SOA but preferable standards to achieve the SOA.
Posted Date:- 2021-09-19 23:06:03
* The framework can be configured to work independently with SOAP or RSS.
* This a popular communication technology that offers remarkable performance when compared to other Microsoft specifications.
* This framework is suitable for secure communication, data transmission, and even speed can be optimized. It is exchanging data in binary format to decrease the latency.
* This is a distributed management system that is applicable to almost all applications that are developed with WCF.
Posted Date:- 2021-09-19 23:05:40
1. It is used to exchange messages in XML format with the help of HTTP protocol to maintain interoperability.
2. WCF uses remote services to exchange messages in binary format with the help of TCP protocol to maintain performance.
3. A service to exchange data securely over the network in real-time.
Posted Date:- 2021-09-19 23:04:56
Every WCF services must be hosted somewhere. There are three ways of hosting WCF services.
They are
* IIS
* Self Hosting
* WAS (Windows Activation Service)
Posted Date:- 2021-09-19 23:03:18
Address is a way of letting client know that where a service is located. In WCF, every service is associated with a unique address. This contains the location of the service and transport schemas.
WCF supports following transport schemas
HTTP
TCP
Peer network
IPC (Inter-Process Communication over named pipes)
MSMQ
The sample address for above transport schema may look like
http://localhost:81
http://localhost:81/MyService
net.tcp://localhost:82/MyService
net.pipe://localhost/MyPipeService
net.msmq://localhost/private/MyMsMqService
net.msmq://localhost/MyMsMqService
Posted Date:- 2021-09-19 23:02:41
A service is a unit of functionality exposed to the world.
The client of a service is merely the party consuming the service.
Posted Date:- 2021-09-19 23:02:19
The three core components of WCF are as follows:
1. Service class: In the runtime layer, you will find the behaviors that occur only when a service is actually running, i.e., the runtime behaviors of the service. Throttling is used to control the number of messages processed that can be altered if the service grows to a preset limit.
2. Endpoint: WCF Service makes available a set of endpoints. All Endpoints are portals through which users are able to communicate with the outside world. Endpoints are composed of three components: Address, Binding, and Contract.
3. Hosting Environment: It is the host application that is responsible for controlling the service's lifetime. Self-Hosting or management of services can be done by the existing hosting process.
Posted Date:- 2021-09-19 23:01:59
WCF has the following benefits:
* Performs better than other Microsoft specifications.
* Secure communication, data transmission, or even speed optimization can be achieved.
* Decrease the latency by exchanging data in binary format.
* Comparatively more reliable and secure than ASMX Web services.
* Using the security model and altering the binding does not require a lot of coding changes.
* A few changes to the configuration file will meet your needs.
* Ensures interoperability between services.
* Multiple hosting options are available such as IIS, WAS, self-Hosting.
Posted Date:- 2021-09-19 23:00:49
SOA stands for **service-oriented architecture. Service Oriented Architecture is an architectural approach in software development where the application is organized as "Services". Services are a group of methods that contain the business logic to connect a DB or other services. For instance you go to a hotel and order food. Your order first goes to the counter and then it goes to the kitchen where the food is prepared and finally the waiter serves the food.
Some important characteristics of Service Oriented Architecture
* SOA services should be independent of other services. Altering a service should not affect the client calling the service.
* Services should be self-contained. Services should be able to define themselves (in the Web Service Description Language (WSDL)). It should be able to tell the client what all of the operations it does, what are all the data types it uses and what kind of value it will return.
Posted Date:- 2021-09-19 22:59:49
Windows Communication Foundation (WCF) is a framework for building service-oriented applications. Using WCF, you can send data as asynchronous messages from one service endpoint to another. A service endpoint can be part of a continuously available service hosted by IIS, or it can be a service hosted in an application. An endpoint can be a client of a service that requests data from a service endpoint. The messages can be as simple as a single character or word sent as XML, or as complex as a stream of binary data.
Posted Date:- 2021-09-19 22:59:14