Search code examples
restwcfiissoapiis-8

Strange IIS/WCF Web Service Issue


Windows Server 2012 - IIS 8.x

I have a WCF web service (DLL) deployed in IIS that supports SOAP and REST over https. There is a certificate installed from Comodo for the SSL.

When I create a proxy for the service in C# apps everything works fine. Also, when I call most of the REST methods from a browser or from Postman they also work fine.

But there are a few REST methods that fail with no exception. In Chrome browser I get an error that says: "This site can't be reached." In Postman I get an error that says: "Could not get any response."

When I check the code in the WCF service I can see that the method gets called and actually executes with no exception, but nothing is returned. I've also checked the IIS logs and I don't seem to see any errors.

Here is an example of a method that works fine:

[OperationContract]
[WebGet(ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "/GetActivityRules?agencyID={agencyID}")]
List<ActivityRule> GetActivityRules(int agencyID);

Yet, this method fails:

[OperationContract]
[WebGet(ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "/GetActivity?agencyID={agencyID}&userID={userID}&date={date}&view={view}")]
List<Activity> GetActivity(int agencyID, int userID, string date, string view);

Has anyone experienced this before or have any ideas why this is happening or how best to troubleshoot?

UPDATE #1

I added code to the GetActivity function that writes to a log file each time its called. I can see the function executes correctly without error each time, but still there is no response. Makes me wonder if the problem is not related to WCF. I also added a trace listener to web config, but the file never gets created.

<system.diagnostics>
      <sources>  
            <source name="System.ServiceModel"   
                    switchValue="Information, ActivityTracing"  
                    propagateActivity="true">  
            <listeners>  
               <add name="traceListener"   
                   type="System.Diagnostics.XmlWriterTraceListener"   
                   initializeData= "C:\Samadhi\TraceLog.svclog" />  
            </listeners>  
         </source>  
      </sources>  
   </system.diagnostics>

UPDATE #2

I spent a week of mind numbing searching, reading, and checking everything I possibly could with no result. I raised a support issue with Microsoft, which was escalated to one of their senior engineers. They have spent two days looking into the problem with still no solution. They tell me they have never seen this before!


Solution

  • How frustrating software development can be. I swear I'm going to need hair replacement therapy soon. I finally found what was causing the issue, and as is most often the case, it boils down to my programming error. The frustrating part is when you have no error message, or when a framework throws a generic error that gives no clue as to what's wrong.

    The issue came down to the fact that WCF was unable to return the JSON result - unable to parse the list of objects into JSON. This happened because an uninitialised date value was outside the allowed min and max values. The net result was no response from the server, not even an error code. When calling the same method using SOAP, the XML parsed fine - only the REST call was failing.

    I initially had problems setting up WCF trace. For some reason it was causing the service to stop working. And because it was a production server, I had only limited time frames to work with when making config changes. Finally after seeing the JSON error message I knew what to do to fix the problem.