如何调试WCF服务?WCF

2023-09-06 17:05:03 作者:等风来

我有托管在我的Windows应用程序的WCF RESTful服务。

I have a WCF Restful service hosted in my windows application.

在客户服务的移动应用。

The clients to the service are mobile applications.

的客户机调用服务和消息被传递给应用程序,并执行工作

The clients call the service and messages are passed to the application and work is executed.

这是我面临的问题是,应用程序在大多数情况下正常工作。但它没有对一些机器和网络设置工作。

The issue that i am facing is that the application works fine in most of the cases. But it doesnt work on some machines and network settings.

要给出一个更好的主意: 该应用程序不能正常工作在连接到路由器A现在是我改变并连接到路由器B机器上1,相同的应用程序开始工作,在同一台机器上。

To give a better idea : The app is not working on machine 1 connected to router A. Now as i change and connect it to router B, the same app starts working on the same machine.

同样,应用程序不能正常使用的连接到路由器A.现在我改机并保持连接到同一个路由器计算机1,应用程序工作正常。

Similarly, the app is not working on machine1 connected to router A. Now as i change the machine and remain connected to the same router, the app works fine.

我无法弄清楚的问题。关于如何调试这个问题的任何想法?

I am not able to figure out the problem. Any idea on how to debug this issue?

任何帮助AP preciated。

Any help appreciated.

推荐答案

我要开启跟踪和WCF服务消息记录。这可以在服务的web.config / app.config文件来完成,通过Visual Studio中的WCF服务配置工具,它是在工具菜单下(注可用最容易:一旦你一次打开这个工具,你将能够关闭它,然后用鼠标右键单击您的应用程序/网络config文件,并从您的Visual Studio会话期间上下文菜单中选择编辑WCF配置,并自动打开该文件的工具)。在WCF配置编辑器,定位到诊断部分,你可以把跟踪和消息日志记录。注意在那里正在创建的日志文件和/或调整的路径的更期望的位置。我也建议打开自动冲洗,使信息更频繁地写入日志。您可能需要周期跟踪会话后的服务,以确保该日志文件包含所有相关信息。

I would turn on tracing and message logging in the WCF service. This can be done in the web.config/app.config file of the service, most easily via the WCF Service Configuration tool in Visual Studio which is available under the tools menu (note: once you open this tool once, you will be able to close it and then right click on your app/web .config file and select 'edit WCF configuration' from the context menu for the duration of your Visual Studio session and have the file open automatically in the tool). On the WCF Configuration editor, navigate to the Diagnostics section and you can turn Tracing and Message logging on. Note where the log files are being created and/or adjust the path to a more desired location. I would also recommend turning on autoflush, so information is written to the logs more frequently. You may want to cycle the service after a tracing session to make sure that the log files contain all relevant information.

现在,从非工作配置击中该服务。检查使用svctraceviewer.exe,你可以找到你的SDK文件夹下的程序文件的日志。看看是否有什么跳出你的日志中,如果没有则清除现有的日志文件在服务器上,并检查一组日志文件从一个有效的会话试图对比的差异。

Now, hit the service from the non working configuration. Examine the logs using svctraceviewer.exe which you can find in your SDK folder under program files. See if anything jumps out at you in the logs, if not then purge the existing log files on the server and examine a set of log files from a valid session to attempt to contrast the differences.

下面是一个链接到MSDN关于WCF跟踪可能会有所帮助: http://msdn.microsoft.com/en-us/library/ms730342.aspx

Here is a link to msdn regarding WCF tracing which may be helpful: http://msdn.microsoft.com/en-us/library/ms730342.aspx