views:

21

answers:

1

Hi All,

I have a very simple Ajax enabled WCF service that should return a single Entity of type EntityObject serialized to JSON.

Here is my .svc file:

[ServiceContract(Namespace = "FASServices")]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class FASService
{
    [OperationContract, WebGet(ResponseFormat=WebMessageFormat.Json)]
    public FrameAttributes GetFrameAttributes(long frameID)
    {
        var data = FrameAttributeAccessor.GetFrameAttributes(frameID);

        WebOperationContext.Current.OutgoingResponse.Format = WebMessageFormat.Json;

        return data;
    }
}

I have consumed this service in an ASP.Net page via service reference on the ScriptManager and have access a service proxy generated as a result.

Here is my web.config:

 <system.serviceModel>
  <behaviors>
   <endpointBehaviors>
    <behavior name="FASAdmin.FASServiceAspNetAjaxBehavior">
     <enableWebScript />
    </behavior>
   </endpointBehaviors>
  </behaviors>
  <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  <services>
   <service name="FASAdmin.FASService">
    <endpoint address="" behaviorConfiguration="FASAdmin.FASServiceAspNetAjaxBehavior"
     binding="webHttpBinding" contract="FASAdmin.FASService" />
   </service>
  </services>
 </system.serviceModel>

When calling the service I can see the XHR leaving my browser (via FireBug), and can also see the ASP.Net development server receive the HTTP request and subsequently invoke the service which performs a simple lookup using a passed business key via my data access layer (I have a breakpoint on the return statement above, and can inspect the returned entity).

However once control leaves my service code and returns, a response is never sent to my browser and subsequently the JSON serialized data is never received, there is not even any Response Headers to inspect.

Does anyone know why this might be the case? Can anyone offer any techniques into debugging the WCF stack to trace the message end-to-end?

Thanks in advance.

+1  A: 

How to trace WCF serialization issues / exceptions, i.e. you have to enable WCF diagnostic tracing.

Artem K.
The link to WCF Tracing in this answer helped me track and find the serialisation error. Cheers.
James