3.3 建立WebService
Web Servcie最主要的优点是,使用不同程序和在不同系统平台上开发出来的程序,都可以相互通信。另外它还可以跨防火墙地通信,集成了应用程序,集成了B2B,可重用软件和数据等等。下面是WebService 主要代码:
PersonMain.asmx:
....................
[WebMethod]
public DataSet PersonMain(DateTime birthday_from,DateTime birthday_to)
{
// Create the Database object, using the default database service.
// The default database service is determined through configuration.
Database db = DatabaseFactory.CreateDatabase();
string Command = "Person_Procedure";
//The Person_Procedure is the name of procedure.
DBCommandWrapper dbCommandWrapper = db.GetStoredProcCommandWrapper(Command);
dbCommandWrapper.AddInParameter("birthday_from",DbType.DateTime,birthday_from);
dbCommandWrapper.AddInParameter("birthday_to",DbType.DateTime,birthday_to);
//Bothe @birthday_from and @birthday_to are the parameter of procedure.
DataSet ds = null;
ds= db.ExecuteDataSet(dbCommandWrapper);
// Note: connection was closed by ExecuteDataSet method call
//return productsDataSet;
return ds;
}