WCF 审计/日志记录
我需要在 WCF 服务中提供不可否认性,并且希望将所有传入的 SOAP 请求以及签名/安全数据和所有信封内容存储到 SQL Server 数据库中。
这样,当出现问题时,我们可以告诉客户“嗨,这是您签名的消息”与您所写的一模一样。 为此,我需要存储 SOAP 信封 XML 和我的持久业务对象/事务之间的关系。
示例:THIS 是用于将客户 ID=4567 添加到我的客户数据表的 SOAP 信封。
我需要在 SOAP 信封和我的应用程序执行的业务事务之间建立链接。存储记录消息的@@identity 可能是一个解决方案。但是,我该把它放在哪里呢?在 SOAP 主体中?留在记忆中吗?
我读过有关 WCF 日志记录的内容,并编写了一个数据库记录器,它将日志信息而不是文本文件插入表中,但我不知道如何将此数据与解析/反序列化的业务数据契约链接起来到达我的 WCF 服务方法的对象。 我什至不知道这是否是正确的方法!
任何模式/提示/提示/工具/帮助将不胜感激。 谢谢。
I need to provide non repudiation in my WCF services and want to store all my incomming SOAP requests into a SQL server DB with signature/security data and all the envelope stuff.
This way, when a problem occurs, we can tell to the client "Hi, THIS is your signed message" exactly as you wrote it.
To do this, I need to store a relationship between the SOAP envelope XML's and my persisted bussiness objects/transactions.
Example: THIS is the SOAP Envelope used to add Customer ID=4567 to my Customers datables.
I need to establish a link between SOAP envelope and the bussiness transaction performed by my app. Storing @@identity of the logged message could be a solution. But, where do I put it? In the SOAP Body? Keep it in memmory?
I've reading about logging in WCF and wrote a Database Logger that inserts into tables the log info instead a text file, but i don't know how to link this data with the parsed/deserialized bussines datacontract object that arrives to my WCF service's method.
I don't even know if this is the rigth approach!
Any pattern/tip/hint/tool/help would be appreciated.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您已启用 WCF 的消息日志记录功能 (http://msdn.microsoft .com/en-us/library/ms730064.aspx),您可以编写自定义侦听器,并在那里添加您需要的所有逻辑。要编写自定义侦听器,您只需实现 TraceListener 接口(相当简单),然后配置 WCF 来使用它,将其添加到 system.diagnostics 内的侦听器部分,替换默认侦听器。
If you have enabled the message logging feature of WCF (http://msdn.microsoft.com/en-us/library/ms730064.aspx), you can write a custom listener, and there add all the logic you need. To write a custom listener you only have to implement the TraceListener interface (fairly simple) and then configure WCF to use it, adding it to the listeners section inside the system.diagnostics, replacing the default listener.