WebService属性和方法
来源:互联网 发布:数据质量常用度量维度 编辑:程序博客网 时间:2024/04/30 07:07
如果需要在Client和Server端保持状态信息,则可以使用EnableSession属性。缺省情况下EnableSession为false。
WebService端代码:
Public Property Connect() As String
<WebMethod(EnableSession:=True)> Get
Return Session("_str")
End Get
<WebMethod(EnableSession:=True)> Set(ByVal Value As String)
Session("_str") = Value
End Set
End Property
Public Property SQL() As String
<WebMethod(EnableSession:=True)> Get
Return Session("_str1")
End Get
<WebMethod(EnableSession:=True)> Set(ByVal Value As String)
Session("_str1") = Value
End Set
End Property
然后在VB.NET的Applicaton中可以安装如下方式调用上述Web Service:
如下只是一个简单的测试代码,可供参考:
在Button2_Click方法中可以第二次获取Session("_str")的值,不需要重新再赋值。
Imports System.Net
Dim ws As localhost.HelloWorld = New localhost.HelloWorld()
……
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ws.CookieContainer = New CookieContainer()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strTemp As String
ws.set_Connect("Connected!")
strTemp = ws.get_Connect()
TextBox1.Text = TextBox1.Text & strTemp
ws.set_SQL("SQL")
strTemp = ws.get_SQL()
TextBox1.Text = TextBox1.Text & Chr(13) & Chr(10) & strTemp
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
TextBox1.Text = TextBox1.Text & ws.get_Connect()
End Sub
- WebService属性和方法
- WebService 属性
- 关于C#-POST方法和WebService方法
- Ajax 方法和属性
- ASPHTTP属性和方法
- 2.2 方法和属性
- DOMDocument 属性和方法
- dom属性和方法
- DOMDocument 属性和方法
- DOMDocument 属性和方法
- jsEvent属性和方法
- InvokeRequie方法和属性
- 属性和方法
- Utilities属性和方法
- 函数属性和方法
- Python属性和方法
- 数字属性和方法
- Ajax 方法和属性
- WTL 用的 stdafx.h
- 转nginx设置
- 15.2 进程间通信_管道
- VS2005.net自定义控件显示在工具栏上
- 在内核中访问 文件系统里的文件。
- WebService属性和方法
- 打开窗口即最大化html代码
- action script note
- U-boot实现的功能
- 健康理念
- android源码,SDK及ADT编译
- 对象引用
- 一些想法
- php中swfupload上传不能判断登录状态.