我如何拦截出站和入肥皂从C#客户端Web代理消息 [英] How Do I Intercept Outbound and Inbound Soap Messages from C# Client Side Web Proxy

查看:128
本文介绍了我如何拦截出站和入肥皂从C#客户端Web代理消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写的UI来测试ASMX Web服务。服务器和客户端.NET。客户端代理一直使用Wsdl.exe用生成的。

I'm writing UI to test an asmx web service. Server and client are .NET. Client proxy has been generated using wsdl.exe.

我想拦截并存储传出和传入的 SOAP的字符串表示形式生成的讯息调用Web代理方法的结果,因此我可以添加一个功能,它会显示该消息只是发送/接收的用户界面。

I would like to intercept and store a string representation of outgoing and incoming SOAP messages generated as a result of calling methods on the web proxy, so I can add a feature to the UI which will show the message just sent/received.

我依稀记得有两个在哪里可以可以添加代码的扩展点对来intecept的消息,但我不记得这是怎么做的。我认为例子我在参与压缩客户端上的消息,并在服务器上反向的某些部分,即使在我的情况,我想存储而不是改变邮件的头脑。

I dimly recall there are two pairs of extension points where code can can be added to intecept the message but I cannot remember how this was done. I think the examples I have in mind involved compressing some part of the message on the client and the reverse on the server, even though in my scenario, I want to store rather than alter the message.

任何提示和帮助感激地接受。

Any hints and help gratefully received.

(我已经部分地实现了一个的SoapExtension,我不明白ChainStream方法是如何工作的,我也不太清楚如何通知SOAP消息已经被困(因为我在实例化SOAP扩展的控制又不是)的监听器。

(I've partially implemented a SoapExtension. I don't understand how the ChainStream method works, and I'm not sure how to notify a listener that a soap message has been trapped (since I'm not in control of instantiating the soap extension).'

推荐答案

您是在正确的轨道上的SoapExtension。你看到的文档和示例在这里?的 http://msdn.microsoft.com/en-us/library/system.web.services.protocols.soapextension.aspx

You're on the right track with SoapExtension. Did you see the documentation and example here? http://msdn.microsoft.com/en-us/library/system.web.services.protocols.soapextension.aspx

与ChainStream的想法是你获得通过,该请求将被写入到网络流,你必须返回一个不同的数据流的选项。所以,如果你要保存的请求的副本,返回一个MemoryStream,这对Web服务客户端将写请求进去,然后在ProcessMessage的调用可以将数据复制出来的那里,它传递给你的用户界面。

The idea with ChainStream is you get passed the network stream that the request would be written to, and you have the option of returning a different stream. So if you want to save a copy of the request, return a MemoryStream, which the web services client will write the request into, and then in the ProcessMessage call you can copy the data out of there and pass it to your UI.

这篇关于我如何拦截出站和入肥皂从C#客户端Web代理消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆