天天看点

在WCF中用TcpTrace工具查看发送和接收的SOAP消息

1、工具地址

2、设置方法

      监听端口,可以自由设置,但是不能够与服务的端口重合,并且该端口还需要在客户端注册

      目标端口:服务端口

在WCF中用TcpTrace工具查看发送和接收的SOAP消息

3、代码配置

var binding = new WSHttpBinding();
 binding.Security.Mode = SecurityMode.Message;


 //Encrypt, can check with Tcp Trace
 binding.Security.Mode = SecurityMode.Message;
 //Not encrypt
 //binding.Security.Mode = SecurityMode.None;


 var factory = new ChannelFactory<IHelloService>(
     binding, new EndpointAddress("http://localhost:8080/HelloService"));


 //Add listening port only at client.
 Uri tcpTraceUri = new Uri("http://localhost:8081/HelloService");
 factory.Endpoint.Behaviors.Add(new ClientViaBehavior(tcpTraceUri));


 var proxy = factory.CreateChannel();
 var result = proxy.Greeting("WCF Message");      

4、监听结果

在WCF中用TcpTrace工具查看发送和接收的SOAP消息

5、其他配置方式

在WCF中用TcpTrace工具查看发送和接收的SOAP消息

参数说明:

Listen on Port:TcpTrace要监听的本机端口

Destination Server:对TcpTrace监听的端口的任何访问都将转发到目标服务器

Destination Port:对TcpTrace监听的端口的任何访问都将转发到目标服务器的这个端口

如在浏览地址栏输入:​​http://127.0.0.1:8080​​​或者​​http://localhost:8080​​,将会自动转发到对​​http://www.google.com:80​​的访问,

继续阅读