Change the WCF SOAP Response XML

独自空忆成欢 提交于 2019-12-24 12:50:26

问题


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.

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:

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?


回答1:


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

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



来源:https://stackoverflow.com/questions/33731692/change-the-wcf-soap-response-xml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!