WCF Message and Channel
Message and Channel
WCF Message is the unit of data exchange between client and service. It consists of several parts, including a body and headers.
WCF runtime is the set of object responsible for sending and receiving message. For example formatting the message, applying security and transmitting and receiving message using various protocol.
Channels are the core abstraction for sending message to and receiving message from an Endpoint. Broadly we can categories channels as
- Handles sending and receiving message from network. Protocols like HTTP, TCP name pipes and MSMQ.
- Implements SOAP based protocol by processing and possibly modifying message. e.g. WS-Security and WS-Reliability.
- Always create the service with Interface->Implementation format, mention the contract in Interface.
- Define the service in Class library and refer the class library in Host project. Don’t use service class in host project.
- Change the instance mode to per call as default.
- Always catch exception using try/catch block and throw exception using FaultException < T >.
- Logging and Include exception should be enable while compiling the project in debug mode. While in production deployment disable the logging and Include exception details.