Click here to Skip to main content
15,885,546 members

WCF Service does not return response to model (MVP) C#

deurebokkn asked:

Open original thread
I created a project with winforms and used the mvp pattern.
The WCF service handles the data control.
From Bussines objects tot Data Transfer objects and back.
Everything works fine until the return statement.

Tested it with an sql statement that shows less customers.
Found the problem but can't figure out a solution without throwing the whole pattern over.
It shows up to 149 customers. When I change the criteria in the sql statement, to more then 149 records to show then it stops at return response and goes in Time Out after 10 minutes.
Maybe a limit on the capacity?


This is a method in the model that is used to make the request and the response.

C#
public IList<KlantModel> GetKlanten(string sortExpression)
{
    var request = PrepareRequest(new KlantRequest());

    request.LoadOptions = new string[] { "Klanten" };
    request.Criteria = new KlantCriteria { SortExpression = sortExpression };
    var response = Client.GetKlanten(request);

    //if (response.CorrelationId != request.RequestId)
    //    throw new ApplicationException("GetKlanten: RequestId and CorrelationId do not match.");

    //if (response.Acknowledge != AcknowledgeType.Success)
    //    throw new ApplicationException(response.Message);

    return Mapper.FromDataTransferObjects(response.Klanten);
}


The request works gets all the data with the wcf.service.
But when the service wants to return the response. It doesn't give an error but goes in time out after 10 min. (See code below)

public KlantResponse GetKlanten(KlantRequest request)
{
    var response = new KlantResponse(request.RequestId);

        IEnumerable<Klant> klanten;
        klanten = _klantDao.GetKlanten(sort);

        response.Klanten = klanten.Select(c =>
        //Transfer BO to DTO
        DataTransferObjectMapper.Mapper.ToDataTransferObject(c)).ToList();
    //This is the part where it doesn't do anything anymore
    return response;
}


The web.config is configured also <servicemodel>.

XML
<system.serviceModel>
    <services>
      <service behaviorConfiguration="behaviorAction" name="NameSpace.Service">
        <endpoint binding="wsHttpBinding" bindingConfiguration="bindingAction" contract="NameSpace.IService">
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="behaviorAction">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
      <wsHttpBinding>
        <binding name="bindingAction" transactionFlow="false" sendTimeout="00:30:00" receiveTimeout="00:30:00">
          <reliableSession enabled="true"/>
        </binding>
      </wsHttpBinding>
    </bindings>
  </system.serviceModel>
</servicemodel>


the response is handled with the response class. Klantrequest.cs

XML
[DataContract(Namespace = "http://www.yourcompany.com/types/")]
public class KlantRequest : RequestBase
{
    /// <summary>
    /// Selection criteria and sort order
    /// </summary>
    [DataMember]
    public KlantCriteria Criteria;

    /// <summary>
    /// Klant object.
    /// </summary>
    [DataMember]
    public KlantDto Klant;
}



Does anyone knows how it comes that just the return doesn't work without any error?

Thanks in advance.
Tags: C#, MVC, Windows Forms, Service

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900