Server side (including code generated by the designer)
Imports system
Imports System.Web.Services
Imports System.Web.Services.protocols
'
_
_
Public Class SOAPSERVICE
Inherits System.Web.Services.Webservice
Public class mysoapheader
Inherits SoapHeader
Public UserName As String
Public Password As String
END CLASS
#REGION "The code" Zone generated by the web service design "
Public Sub new () mybase.new ()
'This call is required for the web service designer. InitializeComponent ()
'Add your own initialization code after INITIALIZECOMPONENT () call
End Sub
'Web service designer essential private components as system.componentmodel.icontainer
'Note: The following procedure is necessary to use the Web Service Designer to modify this process using the Web Service Designer. 'Don't modify it using the code editor.
Private subinitializeComponent ()
Components = new system.componentmodel.container
End Sub
Protected Overloads Overrides Sub Dispose (Byval Disposing as boolean) 'Codegen: This process is required by the Web Service Designer' Do not modify it using the code editor. IF Disposing Thenif Not (Components Is Nothing) ThenComponents.dispose () end ifnd ifmybase.dispose (Disposing) End Sub
#End region
'Add a member variable of the type deriving from soapheader.public Temp as new MysoapHeader
'Apply a soapheader attribute.
SOAPHEADER ("Temp")> _ _
Public function helloworld () AS STRING
If Temp.userName = "admin" then
Return Temp.username
Else: Return "User is empty"
END IF
END FUNCTION
END CLASS
Client (excluding designer) Imports system.web.services.protocols
Dim h As localhost.MySoapHeaderDim myheader As localhost.MySoapHeaderDim proxy As localhost.soapservice = New localhost.soapserviceh = New localhost.MySoapHeaderh.password = "1" h.username = "admin"
Proxy.MysoapHeaderValue = HDIM Results as string = proxy.helloworld
TextBox1.text = resultStextBox2.text = h.username