WCF service does not return response to model
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: WCF service does not return response to model

  1. #1
    Join Date
    Aug 2012
    Posts
    9

    WCF service does not return response to model

    I created a project with winforms and used the mvp pattern.
    The data with validations is transefered with a wcf.service.

    This is the model that is used to make the response.
    Code:
    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("GetCustomers: 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)
    Code:
            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 .
    Code:
    <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>
    Does anyone knows how it comes that just the return doesn't work without any error?

    Thanks in advance.

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    11,219

    Re: WCF service does not return response to model

    What is Client and what is _klantDao?

    It seems that these are class fields and you are keeping connections open after you are finished with them. The problem with this approach is these connections could be in a bad state the next time you attempt to use them (which could result in the problem you are seeing).

  3. #3
    Join Date
    Aug 2012
    Posts
    9

    Re: WCF service does not return response to model

    Client = ServiceReference.Client
    _klantdao = Just the class with the sql statements that returns a list. See below.

    Code:
    public static List<T> ReadList<T>(string sql, Func<IDataReader, T> make, object[] parms = null)
            {
                using (var connection = factory.CreateConnection())
                {
                    connection.ConnectionString = connectionString;
    
                    using (var command = factory.CreateCommand())
                    {
                        command.Connection = connection;
                        command.CommandText = sql;
                        command.SetParameters(parms);
    
                        connection.Open();
    
                        var list = new List<T>();
                        var reader = command.ExecuteReader();
    
                        while (reader.Read())
                            list.Add(make(reader));
    
                        return list;
                    }
                }
            }
    Now I did change the customer table. From 623 records to 18 records and then it works.
    So probably something with the max size of lists...

  4. #4
    Join Date
    Aug 2012
    Posts
    9

    Re: WCF service does not return response to model

    Tested it with a sql statement show less then ... id.
    It shows untill 149 records.
    After it, doesn't returns response.

    Think it is something with the lists capacity.

  5. #5
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    11,219

    Re: WCF service does not return response to model

    Quote Originally Posted by deurebokkn View Post
    Think it is something with the lists capacity.
    Unlikely. In the WCF service code, put a breakpoint on the
    Code:
    return list;
    statement.

    I'll bet the list contains more than 149 records. If it doesn't check out your sql query statement. If it does, you most like have a problem running into the default limit of how much data you can return from the WCF service. To fix, increase the size of maxBufferSize, maxReceivedMessageSize, and maxStringContextLength params inside the binding config.

    Search these in msdn for more info.

  6. #6
    Join Date
    Aug 2012
    Posts
    9

    Re: WCF service does not return response to model

    Worked out.

    Did change app.config in both the model and the Starters project. (had to change in both app.configs)

    What changed:
    - Time out all to 10 minutes.
    - the readerQuotas.
    - maxBufferPoolSize and maxReceivedMessageSize.

    Code:
    <binding name="WSHttpBinding_IOVAService" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
      <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="true"/>
    </binding>
    Thanks a lot for helping.

  7. #7
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    11,219

    Re: WCF service does not return response to model

    Quote Originally Posted by deurebokkn View Post
    Worked out.

    Did change app.config in both the model and the Starters project. (had to change in both app.configs)

    What changed:
    - Time out all to 10 minutes.
    - the readerQuotas.
    - maxBufferPoolSize and maxReceivedMessageSize.

    Thanks a lot for helping.
    You'r welcome. Finding those max size related errors isn't easy because the exceptions you get don't exactly lead you to the problem.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center