How to add custom Http Header for C# Web Service Client consuming Axis 1.4 Web service

前端 未结 7 1734
离开以前
离开以前 2020-11-29 20:33

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 hea

7条回答
  •  失恋的感觉
    2020-11-29 20:46

    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;
    }
    

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

提交回复
热议问题