I have to separate in different machines/servers the different dlls in my n-layered project, I wish to know what would be the most appropriate method to accomplish this. The DAL would be in a different machine and perhaps the BLL would be in a different machine also, I am looking with Web Services as an option here though it would be my first time to delve with web services so I need some guidance here or perhaps you could offer me some alternative route to take other than a web service? I am using DTO (Data Transfer Object) to pass data between layers and I am contemplating, there should be a web service in the DAL that would accept DTOs and pass it to the DAL right? In my current implementation I am using the sample code below to accept, process and pass DTOs (any negative feedback on the implementation is welcome):
I have the ff. concerns which I hope you guys would address:Code:namespace DataAccess { public class DataPortal<T> : IDisposable { private Methods _dataAccess; private bool disposed; public DataPortal() { _dataAccess = new SqlServerDatabase(); } public T FetchOne(string sqlStatement) { Type objectType = typeof(T); object businessObject = null; // Prepare our query _dataAccess.PrepareQuery(sqlStatement); if (_dataAccess.RecordExists()) { businessObject = Activator.CreateInstance(objectType); DataRow dr = _dataAccess.GetDataRow(); for (int b = 0; b < dr.Table.Columns.Count; b++) { // Map the columns to the object's properties string columnName = dr.Table.Columns[b].ColumnName; PropertyInfo field = objectType.GetProperty(columnName); object value = dr[b]; if (!(value is System.DBNull)) field.SetValue(businessObject, dr[b], null); else field.SetValue(businessObject, null, null); } } return (T)businessObject; } public bool Insert(Entities.BusinessObject businessObject) { //Get the INSERT sql statement string stringSql = businessObject.SqlStatement; // Prepare our query _dataAccess.PrepareQuery(stringSql, CommandType.StoredProcedure); // Fill the parameter values for (int a = 0; a <= businessObject.Fields.Count - 1; a++) { if (businessObject.Fields[a].IncludeInSql.Equals(true)) { if (businessObject.Fields[a].FieldValue != null) InsertClassParameter(businessObject.Fields[a]); else _dataAccess.AddParameter(businessObject.Fields[a].FieldName, businessObject.Fields[a].FieldValue); } } int result = (int)_dataAccess.ExecuteActionQuery(); return (result > 0); } } }
1. I wish to know if the above code can be converted to equivalent web methods? Or should I use different web methods for each CRUD of the different DTOs?
2. Upon reading I have learned that web services serializes objects on the background so I wish to know if there is a need for me to actually serialize my DTOs before passing them to the web service? Or did I understand it correctly?
3. What are the best practices when utilizing web services in n-tier applications?
TIA




Reply With Quote