Intercepts WCF messages through custom Behaviors

Source: Internet
Author: User

You can use either of the following methods to expand the WCF: Custom behavior and custom binding. Behavior is used to control internal communication methods, and binding elements are used to create channels that control external communication methods. Specifically, the behavior on the WCF client is used to modify the operations of some components. These components are mainly responsible for serializing the sent data in the message and deserializing the response. On the WCF server, behavior is used to modify the Scheduler Component (dispatcher) function. (The above is the original story in wcf3.5 secrets)

The types of custom behaviors include Operation selector, parameter checker, message formatter, and message checker. The operation selector returns the operation for processing messages. The parameter Checker can modify the called parameters. The message formatter is responsible for deserializing received messages and serializing the messages to be sent; the message Checker can operate and modify a message when the message passes the endpoint.

Based on the above description, we can determine that to intercept a WCF message, we can extend it by customizing the behavior extended WCF, and select the type of behavior to be customized as needed.

The implementation of custom behaviors is divided into three steps:

1. Declaration (implement corresponding interfaces)

2. Attaching (actions can be appended to an operation (implementing ioperationbehavior) or an endpoint (implementing iendpointbehavior ))

3. Notify (use the code or configuration file to notify WCF)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.