2016-10-09 1 views
0

MVC 응용 프로그램을 wcf 서비스에 연결 했으므로 다른 작업에 종속 된 작업을 특징으로하는 할 일 목록 응용 프로그램을 만들려고합니다. 지금까지는이 기능이 없지만 저장된 proc 파일을 빌드했습니다. 이제 WCF 서비스에서 호출하여 클라이언트에게 응답을 보냅니다.데이터리스트를 채우려 할 때 내 WCF 서비스가 시간 초과됩니까?

현재 클라이언트는 1 분 동안 응답하지 않으면 다음 오류를 표시합니다.

"The request channel timed out while waiting for a reply after 00:01:00. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout." 

내 WCF 서비스의 코드는 다음과 같습니다.

public DataTable GetAllDependantTasks(string id) 
     { 
      DataTable dt = new DataTable(); 
      try 
      { 
       using (SqlConnection conn = new SqlConnection()) 
       using (SqlCommand com = new SqlCommand()) 
       { 
        conn.ConnectionString = ConfigurationManager.ConnectionStrings["ToDoDatabase"].ConnectionString; 
        com.Connection = conn; 
        com.CommandText = "usp_GetAllDependantTaskInfoByID"; 
        com.CommandType = CommandType.StoredProcedure; 
        com.Parameters.Add(new SqlParameter("@id", id)); 
        conn.Open(); 
        SqlDataReader returnvalue = com.ExecuteReader(); 

        if (returnvalue.HasRows) 
        { 
         //List<DataRow> items = new List<DataRow>(); 
         dt.Load(returnvalue); 

         // foreach (DataRow row in dt.Rows) 
         // { 
         // items.Add(row); 
         //} 

         return dt; 
        } 
        else 
        { 
         throw new RowNotInTableException(); 
        } 

       } 
      } 
      catch (Exception ex) 
      { 
       //TODO: Write error to log 
       return new DataTable(); 
      } 
     } 

내 프런트 엔드에서 ASPX 페이지를 사용하고 있습니다. 문제가되는 코드는 다음과 같습니다.

private void LoadTasks() 
     { 
      // get the todo list items 
      ToDoService.ToDoServiceClient client = new ToDoService.ToDoServiceClient(); 

      try 
      { 
       // List<ToDoService.ToDoItemContract> toDoItems = client.GetToDoItems("").ToList(); 


     List<string> Items = new List<string>(); 

      foreach(var row in client.GetAllDependantTasks("").Rows) 
       { 
        Items.Add(row.ToString()); 
       } 

       dlTasks.DataSource = Items; 


       dlTasks.DataBind(); 

       client.Close(); 
      } 
      catch (Exception ex) 
      { 
       // TODO: Log error 
       client.Abort(); 
      } 
     } 

아무도 나에게 올바른 방향을 제시 할 수 있습니까? 프론트 엔드에서 프론트 엔드의 데이터리스트를 채우고 싶습니다. 기존 태스크와 함께 의존하는 태스크를 추가하고 싶습니다. wcf 서비스에서 datatable을 리턴하여리스트에 바인드하려고했지만, 좋아할 것 같지 않습니다. ! 사전 :

+0

저장 프로 시저를 독립적으로 테스트 했습니까? 실행됩니까? 또한 WCF 인터페이스 및 계약서를 게시하십시오. –

답변

0

에서

덕분에 어쩌면 반환 된 데이터는 많은이며 시간이 걸립니다. SqlCommand의 기본 시간 제한은 15 초입니다.

당신은

com.Connection = conn; 
com.CommandTimeout = 0; 

이 연결에 대한 시간 제한을 해제 할 무엇을 시도 할 경우 채우기의 실행을 위해 더 많은 시간을 할 수 있습니다. 뭔가 잘못되면 무한정 실행되도록 두지 말고 시간을 밀리 초 단위로 조정하십시오.

그렇지 않은 경우, 기본 WCF의 시간 범위가 당신에게 무슨 일이 일어나고 있는지입니다 1시 때문에 더 긴 시간 범위로 설정

Webservice.InnerChannel.OperationTimeout = TimeSpan.FromMinutes(10); 

와 웹 서비스의 동작 timout을 설정해보십시오.

+0

연결 시간 초과는 읽기 전용입니까? –

+0

@ReeceCottam가 수정되었습니다. 그것은 SqlConnection가 아닌 SqlCommand입니다 –

+0

sqlcommand에는 ConnectionTimeout에 대한 정의가 분명히 포함되어 있지 않습니다. –

관련 문제