Chinaunix首页 | 论坛 | 博客
  • 博客访问: 650072
  • 博文数量: 789
  • 博客积分: 5000
  • 博客等级: 大校
  • 技术积分: 4985
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-28 09:29
文章分类

全部博文(789)

文章存档

2011年(1)

2008年(788)

我的朋友

分类:

2008-10-28 09:48:04


  端(包括设计器生成的代码)
  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
  
  
【责编:admin】

--------------------next---------------------

阅读(461) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~