The method mainly utilizes class inheritance.
Inherit the WEB Service proxy class and add a new method to add information to the header of the SOAP request envelope.
The following is the generated code for the inherited class: GetHttpHeadersProxy. vb
Imports System. Net
Imports System. Collections. Specialized
Public Class GetHttpHeadersProxyClass GetHttpHeadersProxy
Inherits getheaders. header
Private headerstoadd As NameValueCollection
Public Sub New ()
Headerstoadd = New NameValueCollection
End Sub
Public Sub addhttpheader () Sub addhttpheader (ByVal headername As String, ByVal headervalue As String)
Headerstoadd. Add (headername, headervalue)
End Sub
Protected Overrides Function GetWebRequest () Function GetWebRequest (ByVal uri As Uri) As WebRequest
Dim request As WebRequest
Request = MyBase. GetWebRequest (uri)
Request. Headers. Add (headerstoadd)
Return request
End Function
End Class
The highlighted green background is the reference class generated for the WEB service.
The following method is used for usage: dim proxy as GetHttpHeadersProxy = new GetHttpHeadersProxy
Proxy. AddHttpHeader ("name", "aowind ")
Proxy. AddHttpHeader ("sex", "man ")
In this way, you can add the required value to the header of the SOAP request.