SOAP security certification in WebService

xiaoxiao2021-03-06  55

Server side (including code generated by the designer) Imports Systemimports System.Web.ServicesImports 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 generated by the web service designer" public sub new () mybase.new () 'This call is required for the web service designer. InitializationComponent () Add your own initialization code after InitializationComponent (), you have the private component as system.componentmodel.icontainer 'note: the following procedure is required by the following process is the' available The Web Service Designer modifies this process. '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 IfEnd 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

The client (not including designers) 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

转载请注明原文地址:https://www.9cbs.com/read-117083.html

New Post(0)