Modifying SOAP requests with GetWebRequest

房东的猫 提交于 2019-12-10 15:30:34

问题


I am trying to dynamically modify XML data in SOAP requests to ASMX services.

I overrided GetWebRequest() method in SoapHttpClientProtocol class in order to read and modify XML data that the RequestStream contains.

The problem is, the request seems to be empty, there is no data in it whatsoever. Is this because the SOAP data hasn't yet been generated and serialized or am I doing something wrong?


回答1:


What you need is a SoapExtension. You could hook into the SoapMessageStage.AfterSerialize stage in ProcessMessage to modify your soap message. I've done this in the past to add WSSE headers in situations where I couldn't add a dependency on Microsoft's WSE library (since it isn't available for Mono).

Complete tutorial here: http://msdn.microsoft.com/en-us/magazine/cc164007.aspx

GetWebRequest is too early for your purpose, GetWebResponse is too late.



来源:https://stackoverflow.com/questions/8137241/modifying-soap-requests-with-getwebrequest

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