WCF IIS Web Service Strange Intermittent Results

219 views Asked by At

I'm in the process of migrating a WCF web service hosted in IIS from an old server to a new one.

On the new server (Windows 2019) I performed the following steps:

  • created Website & Application Pool in IIS
  • installed SSL certificate
  • added site bindings (http and https)
  • copied project files (DLL’s, SVC, Web.Config) to folder

The folder is under inetpub/wwwroot.

The web service on the old server is working fine and the only difference is the new server has a different domain name and IP address.

I can get the mex metadata by calling https://www.example.com/TestConnect.svc/basic?singleWsdl

When I test the service using Postman (or Chrome), I'm getting strange results. Calling one of the methods returns the correct result (an integer value). I then call another method that should return List<myClass> and I get an error message "Could not get any response". Chrome error says: "This site can't be reached. www.blah.com's server IP address could not be found."

There seems to be no firewall issue and no problem with authentication or the SSL certificate because the successful call returns a result over https and is authenticated with the username & password.

I can see the successful request in IIS log as follows:

GET /TestConnect.svc/json/GetNoteCount token=blahblah 443 TestAPI xxx.xxx.xxx.xxx PostmanRuntime/7.24.1 - 200 0 0 844

Every web request should show in the IIS log but if it doesn't, it's possible that the request never made it to IIS. Knowing that incoming requests to the server are first routed through HTTP.SYS before being handed over to IIS, I checked the HTTPERR log in C:\Windows\System32\LogFiles\HTTPERR

Sure enough the failed request is not in the IIS log but it is in HTTPERR as follows:

2020-10-13 11:11:55 xxx.xxx.xxx.xxx 61134 xxx.x.xx.xxx 443 HTTP/1.1 GET /TestConnect.svc/json/GetNotes?token=blah&search=banking - - 3 Request_Cancelled TestAPI

The "s-reason" column shows Request_Cancelled.

I can't see why the request is failing. Anyone have experience with this or any suggestions what is causing it to fail?

1

There are 1 answers

0
Ross Kelly On

After following Lex Li's reference to another overflow question I found out how to get much more detailed error messages. This is the error message I found:

System.Runtime.Serialization.SerializationException: DateTime values that are greater than DateTime.MaxValue or smaller than DateTime.MinValue when converted to UTC cannot be serialized to JSON. System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.

The method I was calling returns a collection List. One of the fields in this list is DateTime (not DateTime?), and the code wasn't populating this field, which results in a datetime value that is invalid and can't be serialized to JSON.

I think the reason I didn't encounter this error before is because I was consuming the web service via a proxy that was generated by the C# client which uses XML not JSON.