WCF follow-up trip (17): Routing Messages via tcptracer

Source: Internet
Author: User
Tags hosting

For readers who want to have a deep understanding of WCF's message exchange, Tcptracer is definitely a great tool. We place tcptracer between service and service agents, and Tcptracer will help us to receive, display, and forward messages that flow through him.

Essentially, Tcptracer is a router. When we start, we need to set two ports: the original port (source ports) and the destination port (destination ports), then Tcptracer will be on the original port for network monitoring. Once the request arrives, he intercepts the entire requested message and displays the entire message to the message panel. Tcptracer then sends the message to the destination port intact. On the other hand, messages sent from the destination port to the original port are also intercepted, displayed, and forwarded by the Tcptracer.

Next we'll show you how to route messages through Tcptracer in WCF through the following steps.

Step one, create a simple WCF application

In order to demonstrate the application of tcptracer in WCF, we need to create a simple application for WCF services, for which we create an example of a simple computing service.

The entire application uses the four-tier structure as shown in the following figure: contracts, Services, hosting, and clients.

Contracts:class Library project, defines all contracts, including service contracts, data contracts, message contracts, and error contracts, which are referenced by three other projects at the same time

Services:class Library project, which implements the service contract defined in contracts

Hosting: Console project, referencing both contracts and services, to implement a boarding service for a serviced project

Clients: Console project, referencing contracts, impersonating the caller of the service

Service Contract: Artech.TcpTraceDemo.Contracts.ICalculate

//---------------------------------------------------------------
// EndpointAddress & WCF Addressing (c) by 2008 Jiang Jin Nan
//---------------------------------------------------------------
using System.ServiceModel;
namespace Artech.TcpTraceDemo.Contracts
{
  [ServiceContract]
  public interface ICalculate
  {
    [OperationContract]
    double Add(double x, double y);
  }
}

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.