奇怪的IIS/WCF Web服务问题 [英] Strange IIS/WCF Web Service Issue

查看:58
本文介绍了奇怪的IIS/WCF Web服务问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Windows Server 2012-IIS 8.x

Windows Server 2012 - IIS 8.x

我在IIS中部署了WCF Web服务(DLL),该服务支持基于https的SOAP和REST.从Comodo安装了SSL证书.

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.

当我在C#应用程序中为服务创建代理时,一切正常.另外,当我从浏览器或Postman调用大多数REST方法时,它们也可以正常工作.

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.

但是有一些REST方法毫无例外地失败了.在Chrome浏览器中,我看到一条错误消息:无法访问此站点."在邮递员中,我看到一条错误消息:无法获得任何响应."

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."

当我检查WCF服务中的代码时,我可以看到该方法被调用并且实际上没有例外地执行,但是什么也没有返回.我还检查了IIS日志,但似乎没有看到任何错误.

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);

但是,此方法失败:

[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?

更新#1

我向 GetActivity 函数添加了代码,该函数每次调用都会写入日志文件.我可以看到函数每次正确执行而没有错误,但是仍然没有响应.让我想知道问题是否与WCF无关.我还向Web配置添加了跟踪侦听器,但是文件从未创建.

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>

更新#2

我花了一个星期的时间来麻木地搜索,阅读和检查我可能无法完成的所有事情.我向Microsoft提出了一个支持问题,该问题已升级为他们的一位高级工程师.他们花了两天的时间来研究问题,但仍然没有解决方案.他们告诉我他们从未见过!

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!

推荐答案

软件开发多么令人沮丧.我发誓我很快将需要头发替代疗法.我终于找到了导致问题的原因,并且在大多数情况下,归结为我的编程错误.令人沮丧的是,当您没有任何错误消息时,或者当框架抛出一个笼统的错误而无法提供任何错误提示时.

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.

问题归结为WCF无法返回JSON结果-无法将对象列表解析为JSON.发生这种情况是因为未初始化的日期值超出了允许的最小值和最大值.最终结果是服务器没有响应,甚至没有错误代码.使用SOAP调用相同的方法时,XML解析良好-仅REST调用失败.

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.

最初,我在设置WCF跟踪时遇到问题.由于某种原因,它导致服务停止工作.而且由于它是生产服务器,因此在进行配置更改时,我只有有限的时间可以使用.最终,在看到JSON错误消息后,我知道该如何解决此问题.

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.

这篇关于奇怪的IIS/WCF Web服务问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆