Adding Custom Http Headers to Web Service Proxy

前端 未结 1 1123
广开言路
广开言路 2020-12-01 08:28

I have an old application that uses the classic Web Service Proxy to interact with a Java Web Service. A while back the Web Service hoster decided to require a custom HTTP h

相关标签:
1条回答
  • 2020-12-01 09:18

    You should be able to do this by overriding the GetWebRequest method of the proxy class in a partial class in a separate file. After calling the base class method, you should be able to modify the returned HttpWebRequest however you like, then return it from the method:

    public partial class MyServiceProxy {
        protected override WebRequest GetWebRequest(Uri uri) {
            HttpWebRequest request = (HttpWebRequest) base.GetWebRequest(uri);
            // do what you will with request.
            return request;
        }
    }
    
    0 讨论(0)
提交回复
热议问题