最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
在Web Service中实现Transaction
时间:2022-07-02 11:27:08 编辑:袖梨 来源:一聚教程网
在Web Service中实现Transaction
.Net Framework为类,WebForm和WebService提供了事务处理功能。
在传统的windows应用程序中,要写一个有事务处理功能的组件不仅要写代码而且要在组件服务中创建一个事务包。这就意味着在任何一台要处理这个事务的机器上,你都不得不打开mmc在COM+应用程序节点下创建一个新包。
.NET Framework使得这一切变得很简单,事实上我们不用在组件服务中作任何事,这一切都是自动完成的。对WebService来说,.NET Framework用Enterprise Services(COM+的替代者)来管理事务,而无需创建一个COM+包。所有管理事务状态的工作都是在幕后完成的。
在webservice中实现这个很简单。
1)在 [WebMethod()]属性中指定transaction的类型。如[ WebMethod ( false, TransactionOption.RequiresNew) ]
以下是TransactionOption的详细列表。
TransactionOption.Disabled Ignore any transaction in the current context.
TransactionOption.NotSupported Create the component in a context with no governing transaction.
TransactionOption.Supported Share a transaction if one exists; create a new transaction if necessary.
TransactionOption.Required Create the component with a new transaction, regardless of the state of the current context.
TransactionOption.RequiresNew Share a transaction if one exists.
2)用[AutoComplete]属性确保Transaction能完成,除非抛出异常。
由此我们可以看出在Web Service中实现Transaction的一点特殊性,即Transaction属性是应用于WebMethod上的。这意味着在webservice中只有设置了TransactionOption后才会应用事务。
.Net Framework为类,WebForm和WebService提供了事务处理功能。
在传统的windows应用程序中,要写一个有事务处理功能的组件不仅要写代码而且要在组件服务中创建一个事务包。这就意味着在任何一台要处理这个事务的机器上,你都不得不打开mmc在COM+应用程序节点下创建一个新包。
.NET Framework使得这一切变得很简单,事实上我们不用在组件服务中作任何事,这一切都是自动完成的。对WebService来说,.NET Framework用Enterprise Services(COM+的替代者)来管理事务,而无需创建一个COM+包。所有管理事务状态的工作都是在幕后完成的。
在webservice中实现这个很简单。
1)在 [WebMethod()]属性中指定transaction的类型。如[ WebMethod ( false, TransactionOption.RequiresNew) ]
以下是TransactionOption的详细列表。
TransactionOption.Disabled Ignore any transaction in the current context.
TransactionOption.NotSupported Create the component in a context with no governing transaction.
TransactionOption.Supported Share a transaction if one exists; create a new transaction if necessary.
TransactionOption.Required Create the component with a new transaction, regardless of the state of the current context.
TransactionOption.RequiresNew Share a transaction if one exists.
2)用[AutoComplete]属性确保Transaction能完成,除非抛出异常。
由此我们可以看出在Web Service中实现Transaction的一点特殊性,即Transaction属性是应用于WebMethod上的。这意味着在webservice中只有设置了TransactionOption后才会应用事务。
相关文章
- 126邮箱快捷登录-126网易邮箱多账号无缝切换 03-28
- 红色沙漠君子之弓怎么获得 君子之弓获取位置参考 03-28
- 淘宝闪购购物车在哪里-淘宝闪购购物车入口怎么打开 03-28
- 洛克王国世界隐藏传送点大全 洛克王国世界全地图秘境传送位置汇总 03-28
- 洛克王国世界圣羽翼王怎么过 圣羽翼王打法思路推荐 03-28
- 毒液突击队尸王打法攻略 毒液突击队尸王Boss通关技巧与阵容搭配 03-28