如何添加自定义HTTP头的C#Web服务客户端耗时轴1.4 Web服务 [英] How to add custom Http Header for C# Web Service Client consuming Axis 1.4 Web service

查看:173
本文介绍了如何添加自定义HTTP头的C#Web服务客户端耗时轴1.4 Web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用C#该Web服务就是Java轴1.4 Web服务客户端。
轴服务需要在授权:基本Base64EncodedToken 头中的HTTP标头值。
我不能找到一种方法来设置视觉studio.net使用Web服务,像正常的WSDL产生refernce也不符合WSE3.0

I'm trying to write a web service client in c# which the webservice is Java Axis 1.4. Axis service requires the Authorization: Basic Base64EncodedToken header value in the HTTP Headers. I can't find a way to set this header in standart ways of consuming web services in visual studio.net, like normal WSDL generated refernce nor with WSE3.0

作为项目使用.NET 2.0开发的,我不能使用WCF。

I can't use WCF as the project is developed using .net 2.0.

有没有办法做到这一点?

Is there any way to do this ?

推荐答案

这似乎原作者已经找到了自己的解决方案,但对于其他人谁送过来寻求增加实际的自定义页眉,如果你有机会mod生成协议代码可以覆盖 GetWebRequest

It seems the original author has found their solution, but for anyone else who gets here looking to add actual custom headers, if you have access to mod the generated Protocol code you can override GetWebRequest:

protected override System.Net.WebRequest GetWebRequest(Uri uri)
{
  System.Net.WebRequest request = base.GetWebRequest(uri);
  request.Headers.Add("myheader", "myheader_value");
  return request;
}

请确保您删除 DebuggerStepThroughAttribute 如果你想踏入它的属性。

Make sure you remove the DebuggerStepThroughAttribute attribute if you want to step into it.

这篇关于如何添加自定义HTTP头的C#Web服务客户端耗时轴1.4 Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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