0

I am trying to use the following class in a Windows Communication Foundation project written in Visual Studio 2012:

[DataContract]
public class SimCoilData : SimInventoryItemData
{
    [DataMember]
    public UnitTemperature? RequiredCoolingHotspot { get; set; }
    [DataMember]
    public UnitTemperature? RequiredHeatingColdspot { get; set; }
    [DataMember]
    public UnitTemperature? HeatingHotspotLimit { get; set; }

    [DataMember]
    public TimeSpan? TimeToRequiredColdspot { get; set; }
    [DataMember]
    public TimeSpan? TimeToRequiredCoolingHotspot { get; set; }
    [DataMember]
    public TimeSpan? TimeToHeatingHotspotLimit { get; set; }

    [DataMember]
    public UnitLength Gauge { get; set; }
    [DataMember]
    public UnitLength Width { get; set; }
    [DataMember]
    public double[] Temperatures { get; set; }

    public SimCoilData() : base() 
    {

    }

}

Before the addition of the Temperatures array, data was being exchanged well between the server and the client. I added the Temperatures array, rebuilt the server application, and ran it. Then, in the client project, I updated the service reference and rebuilt the project. When I run the client, I get an error message that a meaningless reply was received, which could be caused by a few things, including a data contract mismatch. I have verified that the array is being populated on the server side. What is the correct procedure for adjusting my client application to accept the array?

ROBERT RICHARDSON
  • 2,077
  • 4
  • 24
  • 57
  • That already was the correct procedure. Could you give us the full error message? If you don't have a clear error message, you can also turn on WCF tracing on both sides, client and server to see what is going on. https://stackoverflow.com/questions/4271517/how-to-turn-on-wcf-tracing – Marc May 28 '19 at 21:09
  • Thank you. I will look into WCF tracing tomorrow.Well, today, since I see I didn't send this yesterday. – ROBERT RICHARDSON May 29 '19 at 12:20
  • It appears that the problem is that I'm timing out. If the array is small, then I have no problem. But in real life, I'm getting information on 24 objects, four of which have 1,800-element arrays of doubles. It takes about three seconds for each of those four arrays to be loaded. When everything is assembled and sent back to the client, it bombs. When I limit the number of items loaded into the arrays to ten per object, it works. – ROBERT RICHARDSON May 29 '19 at 17:05
  • No, it's not a timeout error. I set short timeouts in the client and got an error message that said the response was not received within the required time. – ROBERT RICHARDSON May 29 '19 at 17:25

1 Answers1

0

The problem appeared to be that I had not reserved enough space in the client for the messages. I found that I could handle 250 doubles per object but not 300 doubles per object. A Google search for "WCF maximum message size" led me to the maxBufferSize and maxReceivedMessageSize parameters. With this configuration for my client, I was able to get all 1800 values in my arrays:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    </startup>
    <system.serviceModel>
      <bindings>
        <netTcpBinding>
          <binding name="NetTcpBinding_ISimShopServiceLib"
            openTimeout="00:01:00"
            closeTimeout="00:00:05"
            sendTimeout="00:01:00"
            receiveTimeout="00:01:00"
            maxBufferSize="5000000"
            maxReceivedMessageSize="5000000">
          </binding>           
        </netTcpBinding>
      </bindings>
      <client>
        <endpoint address="net.tcp://localhost:1236/SimShopService" binding="netTcpBinding"
          bindingConfiguration="NetTcpBinding_ISimShopServiceLib" contract="SimShopServiceReference.ISimShopServiceLib"
          name="NetTcpBinding_ISimShopServiceLib">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
      </client>

    </system.serviceModel>
</configuration>
ROBERT RICHARDSON
  • 2,077
  • 4
  • 24
  • 57