更改 WCF SOAP 响应 XML [英] Change the WCF SOAP Response XML

查看:45
本文介绍了更改 WCF SOAP 响应 XML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个使用网络服务的现有应用程序.现在我想为这个应用程序创建一个新的网络服务.我无权访问此应用程序的来源.在现有的应用程序中,应该可以只更改 wsdl url 定义,一切都像以前一样.

There is an existing application which consumes a webservice. Now I want to make a new webservice for this application. I have no access to the source of this application. In the existing application it should be possible to just change the wsdl url definition and everything works as before.

所以至少,我正在尝试掠夺现有的网络服务.在这种情况下,返回的soap 响应必须与现有响应相同.现在我的问题是:如何更改 wcf 肥皂响应 xml?例如,如果我们在 VS 中创建一个新的 wcf 项目,我们将获得 Service.svc.在这个项目中有一个内置的 wcf 测试客户端:

So at least, I'm trying to prey an existing webservice. In that case the returned soap response must be the same as the existing one. Now my question: How can I change the wcf soap response xml? For example if we create a new wcf project in VS we get the Service.svc. In this project there is a built in wcf test client:

使用 MessageContracts 我无法完成我想要的.使用 IClientMessageInspector 实现,我可以连接响应soap xml 并进行更改,但这仅适用于单独的客户端项目.我想在同一个 webservice 项目中访问这个 soap xml 响应,并在它被发送到 wcf 测试客户端窗口之前进行更改.

With MessageContracts I can't accomplish what I want. With the IClientMessageInspector implementation I'm able to hook up the response soap xml and do changes but this only works from a separate client project. I want access this soap xml response in the same webservice project and do changes before it gets sent out to the wcf test client window.

关于如何做到这一点的任何想法?

Any ideas on how I can do this?

推荐答案

您可以使用 IDispatchMessageInspector 来修改传出响应.https://msdn.microsoft.com/library/ms733104(v=vs.100).aspx

You can use the IDispatchMessageInspector to modify the outgoing response. https://msdn.microsoft.com/library/ms733104(v=vs.100).aspx

即IDispatchMessageInspector 用于检查(和修改)服务器上的消息(适用于传入和/或传出消息).

I.e. IDispatchMessageInspector is what is used to inspect (and modify) the messages on the server (applies to both incoming and/or outgoing messages).

这篇关于更改 WCF SOAP 响应 XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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