简体   繁体   English

更改WCF SOAP响应XML

[英]Change the WCF SOAP Response XML

There is an existing application which consumes a webservice. 现有使用Web服务的应用程序。 Now I want to make a new webservice for this application. 现在,我想为此应用程序创建一个新的Web服务。 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. 在现有的应用程序中,应该只需更改wsdl url定义,一切都将像以前一样工作。

So at least, I'm trying to prey an existing webservice. 因此,至少,我正在尝试捕食现有的Web服务。 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? 现在我的问题是:如何更改wcf soap响应xml? For example if we create a new wcf project in VS we get the Service.svc. 例如,如果我们在VS中创建一个新的wcf项目,则会得到Service.svc。 In this project there is a built in wcf test client: 在此项目中,有一个内置的wcf测试客户端: 在此处输入图片说明

With MessageContracts I can't accomplish what I want. 使用MessageContracts,我无法完成我想要的。 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. 使用IClientMessageInspector实现,我可以连接响应soap xml并进行更改,但这仅在单独的客户端项目中有效。 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. 我想在同一webservice项目中访问此soap xml响应,并在将其发送到wcf测试客户端窗口之前进行更改。

Any ideas on how I can do this? 关于如何执行此操作的任何想法?

You can use the IDispatchMessageInspector to modify the outgoing response. 您可以使用IDispatchMessageInspector修改传出响应。 https://msdn.microsoft.com/library/ms733104(v=vs.100).aspx https://msdn.microsoft.com/library/ms733104(v=vs.100).aspx

Ie IDispatchMessageInspector is what is used to inspect (and modify) the messages on the server (applies to both incoming and/or outgoing messages). 即IDispatchMessageInspector是用于检查(和修改)服务器上消息的对象(适用于传入和/或传出消息)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM