Adding SOAP headers to ASMX service requests

微笑、不失礼 提交于 2019-12-02 00:44:12

问题


We were given a set of ASMX services to consume. We have no say in how these services are implemented. We have generated a number of proxies with wsdl.exe tool but for some reason unknown to me, these generated proxies don't have any means for including custom SOAP headers.

Basically, I need a way to add custom header data to various service calls.

I am aware of existence of SoapExtension class but unfortunately we're not allowed to use that due to supposed performance issues.

Are there any alternative ways of customizing/adding header data in SOAP requests?


回答1:


you can use SoapHeader / SoapUnknownHeader to extend the generated proxy for this:

  • http://msdn.microsoft.com/en-us/library/whew6x7f.aspx
  • http://msdn.microsoft.com/en-us/library/y4t36w86.aspx
  • http://msdn.microsoft.com/en-us/library/system.web.services.protocols.soapheader.aspx

EDIT - as per comments:

To include a custom namespace see the sample code here.



来源:https://stackoverflow.com/questions/8132887/adding-soap-headers-to-asmx-service-requests

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