title: WCF closing connection unexpected when the client expects data
body: <p>I have a simple server/client setup using WCF. My problem is that any method expecting a return value yields in an exception due to a unexpectedly closed connection server </p>
  
  <p><a href="http://pastebin.com/pWse574y" rel="nofollow">Conifguration file on server side</a></p>
  
  <p><a href="http://pastebin.com/WTYJp1nG" rel="nofollow">Configuratoin file on client side</a></p>
  
  <p>All data classes are in an external project within the <code>MSO.ErrorSystem.Shared.Datatypes</code>
  The code calling the method:</p>
  
  <pre><code>using (var client = Util.GetSearchServiceClient())
  {
    ViewBag.Results = client.SearchReports(searchTerm, page, 50);
  }
  </code></pre>
  
  <p><code>Util.GetSearchServiceClient()</code>:</p>
  
  <pre><code>public static SearchServiceClient GetSearchServiceClient()
  {
    SearchServiceClient client = new SearchServiceClient();
      client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
    return client;
  }
  </code></pre>
  
  <p>The method called on server side:</p>
  
  <pre><code> public IEnumerable&lt;Shared.Datatypes.Report&gt; SearchReports(string pSearchterm, int pPageNum, int pPageSize)
      {
          using (var session = DatabaseManager.Instance.DocumentStore.OpenSession())
          {
              return session.Query&lt;Report&gt;().Where(r =&gt; Regex.IsMatch(r.Title, pSearchterm) || Regex.IsMatch(r.Text, pSearchterm))
                                              .OrderBy(r =&gt; r.Open).OrderBy(r =&gt; r.LastEdited).Skip(pPageNum * pPageSize).Take(pPageSize);
          }
      }
  </code></pre>
  
  <p>EDIT: <a href="http://pastebin.com/0FVQ0yDH" rel="nofollow">Exception in question</a></p>