本篇文章给大家分享的是有关VB.NET中怎么创建WEBService,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。VB.NET创建WebService.具体步骤如下: 新建一个
本篇文章给大家分享的是有关VB.NET中怎么创建WEBService,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。
VB.NET创建WebService.
具体步骤如下:
新建一个项目,选择asp.net Web服务,命名为:“WebService For 业务层”。
添加两个sql DataAdapter,一个为Customer_da,它指向NorthWind数据库的Customers表,另一个为Order_da,指向Northwind数据库的Orders表。
然后生成一个Typed DataSet(选择“数据”菜单的“生成数据集”),命名为:Super_ds.
数据库连接已经完成,下一步我们将考虑它与表示层之间的通信,这里我们定义两个方法。一个为:Get_DataSet,它返回一个Super_ds类型的数据集,另一个为:Update_DataSet,它负责更新数据库数据, 方法代码如下:
Public Function Get_Dataset() As super_ds customer_da.Fill(Super_ds1.Customers) order_da.Fill(Super_ds1.Orders) Return Super_ds1 End Function Public Sub Update_Dataset() Super_ds1.AcceptChanges() End Sub
你可以运行测试一下你的VB.net建立WebService,它将提供两个方法。返回的DataSet是以XML表示的。
业务层的完整代码如下:
Imports System.Web.Services Public Class Service1 Inherits System.Web.Services.WebService 'Web Services Designer Generated Code……。 Public Function Get_Dataset() As super_ds customer_da.Fill(Super_ds1.Customers) order_da.Fill(Super_ds1.Orders) Return Super_ds1 End Function Public Sub Update_Dataset() Super_ds1.AcceptChanges() End Sub ' WEB SERVICE EXAMPLE ' The HelloWorld() example service returns the string Hello World. ' To build, uncomment the following lines then save and build the project. ' To test this web service, ensure that the .asmx file is the start page ' and press F5. ' ' Public Function HelloWorld() As String ' HelloWorld = "Hello World" ' End Function End Class
以上就是VB.NET中怎么创建WebService,小编相信有部分知识点可能是我们日常工作会见到或用到的。希望你能通过这篇文章学到更多知识。更多详情敬请关注编程网精选频道。
--结束END--
本文标题: VB.NET中怎么创建WebService
本文链接: https://www.lsjlt.com/news/293129.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-05-16
2024-05-16
2024-05-16
2024-05-16
2024-05-16
2024-05-16
2024-05-16
2024-05-16
2024-05-16
2024-05-16
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0