频道直达 - 专题 - 新闻 - 技巧 - 组网 - 开发 - 安全 - web编程 - 图像 - 操作系统 - 数据库 - 教育 - 旅游 - 健康 - 时尚 - 驱动 - 软件 - 游戏 - 多媒体 - ERP - 讨论组

WEBSERVICE 中的 SOAP 安全认证

来源: 作者: 出处:巧巧读书 2006-07-26 进入讨论组

  服务器端(包括设计器生成的代码)
  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 " Web 服务设计器生成的代码 "
  
  Public Sub New()
  MyBase.New()
  
  '该调用是 Web 服务设计器所必需的。
  InitializeComponent()
  
  '在 InitializeComponent() 调用之后添加您自己的初始化代码
  
  End Sub
  
  'Web 服务设计器所必需的
  Private components As System.ComponentModel.IContainer
  
  '注意: 以下过程是 Web 服务设计器所必需的
  '可以使用 Web 服务设计器修改此过程。
  '不要使用代码编辑器修改它。
  Private Sub InitializeComponent()
  components = New System.ComponentModel.Container
  End Sub
  
  Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
  'CODEGEN: 此过程是 Web 服务设计器所必需的
  '不要使用代码编辑器修改它。
  If disposing Then
  If Not (components Is Nothing) Then
  components.Dispose()
  End If
  End If
  MyBase.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为空"
  End If
  End Function
  End Class
  
  客户端(不包括设计器)
  Imports System.Web.Services.Protocols
  
  Dim h As localhost.MySoapHeader
  Dim myheader As localhost.MySoapHeader
  Dim proxy As localhost.soapservice = New localhost.soapservice
  h = New localhost.MySoapHeader
  h.password = "1"
  h.username = "admin"
  
  proxy.MySoapHeaderValue = h
  Dim results As String = proxy.HelloWorld
  
  TextBox1.Text = results
  TextBox2.Text = h.username巧 巧 读 书:http://www.qqread.com/safe-tech/j681179072.html 更多文章 更多内容请看路由安全配置专题系统安全设置配置安全的操作系统专题,或进入讨论组讨论。
收藏此文】【 】【打印】【关闭
相关图文阅读
频道图文推荐
健 康 咨 询
时 尚 咨 询
巧巧读书宗旨
相关专题
讨论组问题推荐
站内各频道最新更新文档
站内最新制作专题
热门关键字导读
Photoshop教 程照片处理 照片制作 PS快捷键 抠图
计 算 机 故 障XP系统修复
艺 术 与 设 计设计 流媒体 设计欣赏 边框
计 算 机 安 全ARP
站内频道文章精选
巧巧电脑频道编辑信箱  告诉我们您想看的专题或文章