如何向 Web 服务调用添加 HTTP 标头?

发布于 2024-08-02 18:47:16 字数 311 浏览 0 评论 0原文

我正在从控制台应用程序调用 Web 服务 - 全部使用 .NET 上的 C# 进行。

我想向 Web 服务调用添加 HTTP 标头(不是 SOAP 标头)。我该怎么做?

这是我的代码到目前为止的样子:

EatService es = new EatService(); // web service added in Web References
// Add HTTP header X-Info = "extra info" here
string info = es.GetMoreInfo(); // ws call

I'm calling a web service from a console app - all in C# on .NET.

I want to add an HTTP header (not a SOAP header) to the web service call. How do I do this?

This is what my code looks like so far:

EatService es = new EatService(); // web service added in Web References
// Add HTTP header X-Info = "extra info" here
string info = es.GetMoreInfo(); // ws call

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

深海不蓝 2024-08-09 18:47:16

如果您使用 ASMX Web 服务代理(Web 参考),那么这是 将自定义 Http 标头添加到 C# Web 服务代理

If you are using an ASMX web service proxy (Web Reference), then this is a duplicate of Adding Custom Http Headers to C# Web Service Proxy.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文