是Web服务和数据库之间的交易可能吗? [英] Is transaction between a web service and a database possible?
问题描述
我要调用Web服务中插入一条记录在它的数据库中,然后我想插入一条记录在远程数据库中的其他城市,如果Web服务做了手术成功。
I want to call a web service to insert a record in it's database and then I want to Insert a record in a remote database in the other city if web service do the operation successfully.
下面是一个简单示例code:
here is a simplified sample code:
IdentificationSystem.Service Identify = new IdentificationSystem.Service();
string result= Identify.InsertWorkshopInfo(BosWorkshop.WpSvUserName, BosWorkshop.WpSvPassword,BosWorkshop.WkIcode,BosWorkshop.WpName)
if (result==0)//If success
{
Connect to a remote database and then insert a record
}
根据我的样本code。如果通过Web服务和Web服务回报成功插入的数据,但我不能在其他城市的插入远程数据库中的记录会发生什么。
类似的连接松动。
according to my sample code what will happen if data inserted via web service and web service return success but I can't insert the record in remote database in the other city. something like connection loose.
我应该怎么办?我可以用 System.transaction名字空间
在这里?
我写的Web服务code我的自我。
What should I do? Can I use System.transaction name space
here?
I'm writing the web service code my self.
推荐答案
如果两个服务器运行分布式事务处理协调器(MSDTC),然后是,分布式事务是可能的。
If both servers are running the Distributed Transaction Coordinator (MSDTC), then yes, a distributed transaction is possible.
一个 的TransactionScope
事务将自动升级使用DTC。
A TransactionScope
transaction will automatically escalate using the DTC.
但是,它应该考虑的影响:跨服务器长期运行的事务可能是不可取的。另外,还有一些安全和防火墙注意事项。
BUT, it you should consider the implications: a long running transaction across servers is probably not desirable. Also, there are security and firewall considerations.
这篇关于是Web服务和数据库之间的交易可能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!