description="hello ansel,this is a testing web service!")]
public class attributetest : system.web.services.webservice {
[webmethodattribute(description="描述信息:继承了count方法,并且对名称进行重载。执行的是把钱从a用户转帐到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 其实就是所谓的代理类,它负责进行数据传输发送request和接受response的 aa:=httprio2 as attributetestsoap;