У меня есть приложение asp .net, мой уровень доступа к данным - это служба WCF. Я использую VWD Express 2010. Вся структура с высоты птичьего полета выглядит примерно так
[ServiceContract]
public interface IExcelReader
{
[OperationContract]
[FaultContract(typeof(StaffAllocationFault))]
void ReadExcel();
}
public void ReadExcel()
{
DataSet dataCollection = new DataSet();
table = new DataTable("Capacity");
//gets the connection string for the excelsheet with the employee details
//string strCon = ConfigurationManager.ConnectionStrings["capacityDB"].ConnectionString;
string strCon = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\CapacityDB.xlsx;Extended Properties=Excel 12.0";
//gets the predefined filters in the application
string[] filter = GetDefinedFilters();
//creates the connection object
oledbCon = new OleDbConnection(strCon);
try
{
//opens the connection object
openConnection();
string strCmd = "Select * from [Capacity Report Data$]";
//creates the command object
oledbCmd = new OleDbCommand(strCmd, oledbCon);
//fills the datatable using the data adapter
oledbAdapter = new OleDbDataAdapter();
oledbAdapter.SelectCommand = oledbCmd;
oledbAdapter.Fill(table);
dataCollection.Tables.Add(table);
//to trim off the trailing/preceding whitespaces
foreach (DataRow row in table.Rows)
{
int count = 0;
while (count < filter.Count())
{
try
{
row[filter[count]] = row[filter[count]].ToString().Trim();
//if the field is blank
if (row[filter[count]].ToString() == "")
row[filter[count]] = "***";
count++;
}
catch (Exception ex)
{
throw new FaultException<StaffAllocationFault>(new StaffAllocationFault { FaultMessage = "Error while reading through the employee information" }, ex.Message);
}
}
}
}
catch (Exception ex)
{
throw new FaultException<StaffAllocationFault>(new StaffAllocationFault { FaultMessage = "Error while retreiving employee information" }, ex.Message);
}
finally
{
//closes the oledb connection
closeConnection();
}
}
* * 1010
Мой web.config
в интерфейсе пользователя:
<client>
<endpoint address="http://localhost:49171/ExcelReader.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IExcelReader" contract="ExcelService.IExcelReader"
name="BasicHttpBinding_IExcelReader" />
</client>
когда я запускаю приложение, функция в wcf не вызывается. Просьба помочь.