0

I have a WCF endpoint that returns data queried from a database. For a particular call, for example, I know I should receive 175 records. But my WCF code is always only returning 105 records. I am able to obtain the expected 175 records by running the backend stored procedure that the endpoint function executes. Also if I connect to the endpoint with the WCF Test Client, it also obtains 175 records.

I've tried many things (changing bindings, readerquotas, fiddler, etc), but could not determine what is different in my code. Basically my code for test is a winforms app that has a service reference to the endpoint. I increase the maxReceivedMessageSize to 655360000 in my app.config, because the size of the data is large. I'm using WSHttp as my binding. Below is the code that performs the call and returns the 105 records:

var client = new MyDataClient("WSHttpBinding_IMyData");            
var data = client.GetMyDataByDateRange("Location123", DateTime.Now.Date, DateTime.Now.Date).ToList();            
MessageBox.Show(string.Format("Got {0} records", data.Count)); // always 105

Any ideas as to why my code would return an incorrect result set?

DougEC
  • 357
  • 1
  • 6
  • Have you tried to run a profiler on your Database to see what is the query call being made when you invoke your WCF service from the the winforms app? – Rajesh Apr 19 '16 at 16:20
  • @Rajesh I did not use a database profiler... and unfortunately I don't have permission here at my company to profile against the DB. – DougEC Apr 19 '16 at 16:31
  • The best option is to include some logging statements just before the call to the DB is made that would capture all parameters and review to see if they are the same from WCF Test client and your windows forms app – Rajesh Apr 20 '16 at 08:46

1 Answers1

2

That usually means that you are calling 2 different implementations of the service.

Check if the endpoint that you use with WCF Test Client is the same that you have configured in your .config of your application.

Carlos Cuevas
  • 361
  • 3
  • 6
  • I verified that the endpoint in the WcfTestClient and my app.config are the same. I've even wrote my own binding programmatically with the same endpoint URL and still get the same results. – DougEC Apr 19 '16 at 17:50
  • 1
    There is only other possibility. When you use the TestClient you write the parameters as strings. But in your app you are using DateTime.Now.Date. Try using the same strings in your app. – Carlos Cuevas Apr 19 '16 at 18:14
  • 1
    Or maybe you can debug your service so you can see the values of the parameters when it is called from the WCFTestClient and your test application. – Carlos Cuevas Apr 19 '16 at 18:22
  • That was it! I'm not sure 100% why, because the endpoint does expect System.DateTime types. However, when I did a DateTime.Parse("04/19/2016"), then it worked. Apparently DateTime.Date passed to a WCF endpoint function, may not provide just the date part of the DateTime. Either way... thanks again. – DougEC Apr 19 '16 at 19:02
  • Well, remember that even when it expect a DateTime, WCF serialize the request (because it uses SOAP and XML). After that, the service deserialize the request. – Carlos Cuevas Apr 19 '16 at 19:56