description="hello ansel,this is a testing web service!")]
public class attributetest : system.web.services.webservice {
[webmethodattribute(description="描述信息:繼承了count方法,并且對名稱進(jìn)行重載。執(zhí)行的是把錢從a用戶轉(zhuǎn)帳到b用戶......", //messagename="changing messagename", bufferresponse=true, cacheduration=1000, enablesession=true, transactionoption=transactionoption.requiresnew)] public string transmoney(double money) { try { contextutil.enablecommit();//transaction only used to database operation! moneyintoa(money); moneyoutfromb(money); contextutil.setcomplete(); return "transaction successful,total "+money.tostring(); } catch( exception e) { contextutil.setabort(); return "transaction failed! /n/r "+e.message; } } private void moneyintoa(double money) { sqlcommand sqlcom = new sqlcommand("update budget set money=money+"+money.tostring()+" where name='a'"); databaseaccess mydatabase = new databaseaccess(); sqlcom.connection=mydatabase.getconnection(); sqlcom.connection.open(); sqlcom.executenonquery(); sqlcom.connection.close(); //throw new exception("operation failed when transfer money into a!"); }
private void moneyoutfromb(double money) { sqlcommand sqlcom = new sqlcommand("update budget set money=money-"+money.tostring()+" where name='b'"); databaseaccess mydatabase = new databaseaccess(); sqlcom.connection=mydatabase.getconnection(); sqlcom.connection.open(); sqlcom.executenonquery(); sqlcom.connection.close(); //throw new exception("operation failed when transfer money from b!"); }
procedure tform1.bitbtn1click(sender: tobject); var aa:attributetestsoap;//這個就是wsdl下的類接口對象 msg:widestring; bb:double; begin //httprio2 其實就是所謂的代理類,它負(fù)責(zé)進(jìn)行數(shù)據(jù)傳輸發(fā)送request和接受response的 aa:=httprio2 as attributetestsoap;