KB's

Tracing Web Services Exceptions

Problem:

When an exception occurs in some of the Sitefinity WCF RESTful Services, a response with error 500 / Internal server error is returned. This message is not very useful for understanding where and what exactly the problem is:

wcf error

The failing web service seen in Firebug

 

Solution

In such cases, you should enable web services tracing, so that WCF can log all exceptions in a file, that can be reviewed later. The configuration for this is done in the project's web.config file:

1. Open the web.config file

2. Add the following under configuration node:

<system.diagnostics>
    <trace autoflush="true" />
    <sources>
            <source name="System.ServiceModel"
                    switchValue="Information, ActivityTracing"
                    propagateActivity="true">
            <listeners>
               <add name="sdt"
                   type="System.Diagnostics.XmlWriterTraceListener"
                   initializeData= "SdrConfigExample.e2e" />
            </listeners>
         </source>
    </sources>
</system.diagnostics>
 

3. Save the file and reproduce the error again. Once this is done, you should find SdrConfigExample.e2e file created in the root of the web site/project directory. This file contains all the trace data in form of exceptions, stack traces and other helpful information.

The collected data may be seen with a special tool called SvcTraceViewer. It can be found usually under the following directory - C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin on your machine. When you open the trace file with the tool, you will see the requests to the services logged, as well as precise exception messages and stack traces of the code execution. Example output:

Example output

The trace information visualized in SvcTraceViewer.exe

You may use this information to try to resolve the problem. If you believe the problem is specific to Sitefinity, you are welcome to send the trace log file to us - we will get back to you with a suggestion or a solution.

Notes