2011-10-05 5 views
0

데이터 액세스 계층은 WCF 서비스입니다. 나는 VWD 익스프레스는 2010 년 조감도의 전체 구조는이WCF 함수를 호출 할 수 없습니다.

[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(); 
     } 
    } 


public void ReadFromExcel() 
    { 
     try 
     { 
      new ExcelReaderClient().ReadExcel(); 
     } 
     //service specific exceptions 
     catch (FaultException<StaffAllocationFault> ex) 
     { 
      throw new ExceptionLayer.StaffAllocationException("Error while reading from excel", ex); 
     } 
     //generic exceptions 
     catch (Exception genEx) 
     { 
      throw genEx; 
     } 
    } 

같은 것입니다 사용 UI 나의 web.config :

<client> 
     <endpoint address="http://localhost:49171/ExcelReader.svc" binding="basicHttpBinding" 
      bindingConfiguration="BasicHttpBinding_IExcelReader" contract="ExcelService.IExcelReader" 
      name="BasicHttpBinding_IExcelReader" /> 
    </client> 

응용 프로그램을 실행할 때 wcf의 함수가 호출되지 않습니다. Pls 도움.

+0

오류가 있습니까? –

+0

nopes ... 오류가 발생하지 않았습니다. ( – Niranjan

+0

web.config에서 구성한 내용 WCF의 끝점을 지정해야합니다. –

답변

0

Visual Studio에서 IIS의 WCF 서비스 용 가상 디렉터리를 만듭니다. 그런 다음 VS 명령 프롬프트에서 WcfTestClient를 호출하고 WCFTestClient에 wcf 서비스 참조를 추가하려고 시도합니다 (url의 경우 url의 경우 URL은 http://localhost/VirtualDirectoryName/ExcelReader.svc 일 수 있습니다). - 서비스와 메소드에 액세스 할 수있는 경우 도구 - 그렇지 않으면 적절한 오류가 발생합니다

관련 문제