开发者

Ajax Enabled WCF service not responding with data

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 sub开发者_StackOverflow中文版sequently 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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜