将 SOAP 标头添加到 ASMX 服务请求 [英] Adding SOAP headers to ASMX service requests

查看:36
本文介绍了将 SOAP 标头添加到 ASMX 服务请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们获得了一组 ASMX 服务以供使用.我们对如何实施这些服务没有发言权.我们已经使用 wsdl.exe 工具生成了许多代理,但出于某种我不知道的原因,这些生成的代理没有任何方法可以包含自定义 SOAP 标头.

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.

我知道 SoapExtension 类的存在,但不幸的是,由于假定的性能问题,我们不允许使用它.

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

是否有其他方法可以在 SOAP 请求中自定义/添加标头数据?

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

推荐答案

你可以使用 SoapHeader/SoapUnknownHeader 来扩展生成的代理:

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

编辑 - 根据评论:

要包含自定义命名空间,请参阅此处.

To include a custom namespace see the sample code here.

这篇关于将 SOAP 标头添加到 ASMX 服务请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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